Skip to content

Commit

Permalink
fix Redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Dec 19, 2022
1 parent 8e7dd1d commit fd5780d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 1 addition & 3 deletions packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test.each([
['http://localhost:1234/mermaid/#/flowchart.md', 'syntax/flowchart.html'],
['http://localhost/mermaid/#/flowchart.md', 'syntax/flowchart.html'],
['https://mermaid-js.github.io/mermaid/#/flowchart.md', 'syntax/flowchart.html'],
['https://mermaid.js.org/#/flowchart.md', 'syntax/flowchart.html'],
['https://mermaid-js.github.io/mermaid/#/./flowchart', 'syntax/flowchart.html'],
['https://mermaid-js.github.io/mermaid/#/flowchart', 'syntax/flowchart.html'],
['https://mermaid-js.github.io/mermaid/#flowchart', 'syntax/flowchart.html'],
Expand All @@ -31,7 +32,4 @@ test.each([
test('should throw for invalid URL', () => {
// Not mermaid domain
expect(() => getRedirect('https://www.google.com')).toThrowError();

// Not `/mermaid/` path
expect(() => getRedirect('http://localhost/#/flowchart.md')).toThrowError();
});
7 changes: 3 additions & 4 deletions packages/mermaid/src/docs/.vitepress/theme/redirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ export interface Redirect {
const getBaseFile = (link: string): Redirect => {
const url = new URL(link);
if (
(url.hostname !== 'mermaid-js.github.io' &&
url.hostname !== 'mermaid.js.org' &&
url.hostname !== 'localhost') ||
url.pathname !== '/mermaid/'
url.hostname !== 'mermaid-js.github.io' &&
url.hostname !== 'mermaid.js.org' &&
url.hostname !== 'localhost'
) {
throw new Error('Not mermaidjs url');
}
Expand Down

0 comments on commit fd5780d

Please sign in to comment.