Skip to content

Commit d86d7e1

Browse files
committed
Fixes missing last character in path when tomcat sub-root path used
1 parent 133c88b commit d86d7e1

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

‎main/docker-entrypoint.sh‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,19 @@ elif [[ "${EXPORT_URL}" ]]; then
3535
fi
3636
#DRAWIO_SERVER_URL is the new URL of the deployment, e.g. https://www.example.com/drawio/
3737
#DRAWIO_BASE_URL is still used by viewer, lightbox and embed. For backwards compatibility, DRAWIO_SERVER_URL is set to DRAWIO_BASE_URL if not specified.
38-
if [[ "${DRAWIO_SERVER_URL}" ]]; then
39-
echo "window.DRAWIO_SERVER_URL = '${DRAWIO_SERVER_URL}';" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
40-
echo "window.DRAWIO_BASE_URL = '${DRAWIO_BASE_URL:-${DRAWIO_SERVER_URL:0:$((${#DRAWIO_SERVER_URL}-1))}}';" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
38+
# Strip trailing slash from DRAWIO_SERVER_URL to get base URL
39+
if [[ -n "$DRAWIO_SERVER_URL" ]]; then
40+
DRAWIO_BASE_URL_VALUE="${DRAWIO_SERVER_URL%/}"
4141
else
42-
echo "window.DRAWIO_BASE_URL = '${DRAWIO_BASE_URL:-http://localhost:8080}';" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
43-
echo "window.DRAWIO_SERVER_URL = window.DRAWIO_BASE_URL + '/';" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
42+
DRAWIO_BASE_URL_VALUE="http://localhost:8080"
4443
fi
44+
45+
# Write it to PreConfig.js
46+
echo "window.DRAWIO_SERVER_URL = '${DRAWIO_SERVER_URL}';" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
47+
echo "window.DRAWIO_BASE_URL = '${DRAWIO_BASE_URL_VALUE}';" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
48+
4549
# Dynamically update Tomcat context path if DRAWIO_SERVER_URL ends in a subpath
46-
CONTEXT_PATH=$(echo "${DRAWIO_SERVER_URL}" | awk -F'/' '{print "/"$NF}' | sed 's/\/$//')
50+
CONTEXT_PATH=$(echo "${DRAWIO_SERVER_URL}" | awk -F'/' '{print "/"$NF}' | sed -E 's/[?#].*$//;s/\/$//')
4751

4852
if [ -n "$DRAWIO_SERVER_URL" ] && [ "$CONTEXT_PATH" != "/" ]; then
4953
echo "Updating Tomcat context path to '${CONTEXT_PATH}'"

0 commit comments

Comments
 (0)