mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 15:30:03 +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:1234/mermaid/#/flowchart.md', 'syntax/flowchart.html'],
|
||||||
['http://localhost/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.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'],
|
['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', () => {
|
test('should throw for invalid URL', () => {
|
||||||
// Not mermaid domain
|
// Not mermaid domain
|
||||||
expect(() => getRedirect('https://www.google.com')).toThrowError();
|
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 getBaseFile = (link: string): Redirect => {
|
||||||
const url = new URL(link);
|
const url = new URL(link);
|
||||||
if (
|
if (
|
||||||
(url.hostname !== 'mermaid-js.github.io' &&
|
url.hostname !== 'mermaid-js.github.io' &&
|
||||||
url.hostname !== 'mermaid.js.org' &&
|
url.hostname !== 'mermaid.js.org' &&
|
||||||
url.hostname !== 'localhost') ||
|
url.hostname !== 'localhost'
|
||||||
url.pathname !== '/mermaid/'
|
|
||||||
) {
|
) {
|
||||||
throw new Error('Not mermaidjs url');
|
throw new Error('Not mermaidjs url');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user