mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 14:59:53 +02:00
fix Redirect
This commit is contained in:
@@ -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'],
|
||||
@@ -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();
|
||||
});
|
||||
|
@@ -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');
|
||||
}
|
||||
|
Reference in New Issue
Block a user