fix(#1914): Resolve redirectURL considering base path

This commit is contained in:
Sidharth Vinod
2026-03-30 21:24:33 +05:30
parent c675dc02e9
commit c799dff042
7 changed files with 21 additions and 1 deletions
+1
View File
@@ -1,4 +1,5 @@
MERMAID_DOMAIN='' MERMAID_DOMAIN=''
MERMAID_BASE_PATH=''
MERMAID_DOCS_URL='https://mermaid.js.org' MERMAID_DOCS_URL='https://mermaid.js.org'
MERMAID_ANALYTICS_URL='' MERMAID_ANALYTICS_URL=''
MERMAID_RENDERER_URL='https://mermaid.ink' MERMAID_RENDERER_URL='https://mermaid.ink'
+1
View File
@@ -21,6 +21,7 @@ ARG MERMAID_DOMAIN
ARG MERMAID_IS_ENABLED_MERMAID_CHART_LINKS ARG MERMAID_IS_ENABLED_MERMAID_CHART_LINKS
ARG MERMAID_PRIVACY_POLICY_URL ARG MERMAID_PRIVACY_POLICY_URL
ARG MERMAID_HIDE_PRIVACY_POLICY ARG MERMAID_HIDE_PRIVACY_POLICY
ARG MERMAID_BASE_PATH
COPY . ./ COPY . ./
+2
View File
@@ -28,6 +28,8 @@ If you want to speed up the progress for mermaid-live-editor, join the Discord c
docker run --platform linux/amd64 --publish 8000:8080 ghcr.io/mermaid-js/mermaid-live-editor docker run --platform linux/amd64 --publish 8000:8080 ghcr.io/mermaid-js/mermaid-live-editor
``` ```
The published docker image is built using our default environment variables. You cannot override them when running the image. If you need to customize them, you will need to build the image yourself.
### To configure renderer URL ### To configure renderer URL
When building set the MERMAID_RENDERER_URL build argument to the rendering When building set the MERMAID_RENDERER_URL build argument to the rendering
+1
View File
@@ -48,6 +48,7 @@
"chai": "^4.5.0", "chai": "^4.5.0",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"cssnano": "^6.1.2", "cssnano": "^6.1.2",
"dotenv": "^17.3.1",
"eslint": "^9.39.2", "eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8", "eslint-config-prettier": "^10.1.8",
"eslint-plugin-es": "^4.1.0", "eslint-plugin-es": "^4.1.0",
+9
View File
@@ -165,6 +165,9 @@ importers:
cssnano: cssnano:
specifier: ^6.1.2 specifier: ^6.1.2
version: 6.1.2(postcss@8.5.3) version: 6.1.2(postcss@8.5.3)
dotenv:
specifier: ^17.3.1
version: 17.3.1
eslint: eslint:
specifier: ^9.39.2 specifier: ^9.39.2
version: 9.39.2(jiti@2.6.1) version: 9.39.2(jiti@2.6.1)
@@ -1996,6 +1999,10 @@ packages:
domutils@3.2.2: domutils@3.2.2:
resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==} resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==}
dotenv@17.3.1:
resolution: {integrity: sha512-IO8C/dzEb6O3F9/twg6ZLXz164a2fhTnEWb95H23Dm4OuN+92NmEAlTrupP9VW6Jm3sO26tQlqyvyi4CsnY9GA==}
engines: {node: '>=12'}
dunder-proto@1.0.1: dunder-proto@1.0.1:
resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
@@ -6021,6 +6028,8 @@ snapshots:
domelementtype: 2.3.0 domelementtype: 2.3.0
domhandler: 5.0.3 domhandler: 5.0.3
dotenv@17.3.1: {}
dunder-proto@1.0.1: dunder-proto@1.0.1:
dependencies: dependencies:
call-bind-apply-helpers: 1.0.2 call-bind-apply-helpers: 1.0.2
+3 -1
View File
@@ -1,3 +1,5 @@
import { resolve } from '$app/paths';
/** /**
* Build the redirect URL for legacy root-path links. * Build the redirect URL for legacy root-path links.
* Extracts the route and fragment from the old hash-based URL format, * Extracts the route and fragment from the old hash-based URL format,
@@ -11,5 +13,5 @@ export const buildRedirectUrl = (location: Location): string => {
path = parts[1]; path = parts[1];
fragment = `#${parts[2]}`; fragment = `#${parts[2]}`;
} }
return `/${path}${location.search}${fragment}`; return `${resolve(`/${path}`, {})}${location.search}${fragment}`;
}; };
+4
View File
@@ -1,4 +1,5 @@
import adapter from '@sveltejs/adapter-static'; import adapter from '@sveltejs/adapter-static';
import 'dotenv/config';
import { sveltePreprocess } from 'svelte-preprocess'; import { sveltePreprocess } from 'svelte-preprocess';
/** @type {import('@sveltejs/kit').Config} */ /** @type {import('@sveltejs/kit').Config} */
@@ -10,6 +11,9 @@ const config = {
alias: { alias: {
'$/*': './src/lib/*' '$/*': './src/lib/*'
}, },
paths: {
base: process.env.MERMAID_BASE_PATH ?? ''
},
adapter: adapter({ adapter: adapter({
pages: 'docs', pages: 'docs',
fallback: '404.html' fallback: '404.html'