diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/helpers/url-helpers.test.ts | 3 | ||||
-rw-r--r-- | src/helpers/url-helpers.ts | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/helpers/url-helpers.test.ts b/src/helpers/url-helpers.test.ts index 5ea6fa1a8..e6036893e 100644 --- a/src/helpers/url-helpers.test.ts +++ b/src/helpers/url-helpers.test.ts | |||
@@ -73,6 +73,9 @@ describe('url_helpers', () => { | |||
73 | it('handles string starting with http://', () => { | 73 | it('handles string starting with http://', () => { |
74 | expect(url_helpers.fixUrl('http://some/random/url')).toEqual('http://some/random/url'); | 74 | expect(url_helpers.fixUrl('http://some/random/url')).toEqual('http://some/random/url'); |
75 | expect(url_helpers.fixUrl('http://some//random//url')).toEqual('http://some/random/url'); | 75 | expect(url_helpers.fixUrl('http://some//random//url')).toEqual('http://some/random/url'); |
76 | |||
77 | const gmailEmbeddedUrl = 'https://www.google.com/url?q=https://github.com/ferdium/ferdium-app/issues/87&source=gmail'; | ||
78 | expect(url_helpers.fixUrl(gmailEmbeddedUrl)).toEqual(gmailEmbeddedUrl); // it should NOT remove the double-slash from the embedded url in the query string | ||
76 | }); | 79 | }); |
77 | 80 | ||
78 | it('handles string starting with https://', () => { | 81 | it('handles string starting with https://', () => { |
diff --git a/src/helpers/url-helpers.ts b/src/helpers/url-helpers.ts index 1eda325da..720f242b4 100644 --- a/src/helpers/url-helpers.ts +++ b/src/helpers/url-helpers.ts | |||
@@ -24,7 +24,7 @@ export function isValidExternalURL(url: string | URL) { | |||
24 | } | 24 | } |
25 | 25 | ||
26 | export function fixUrl(url: string | URL) { | 26 | export function fixUrl(url: string | URL) { |
27 | return url.toString().replaceAll('//', '/').replace('http:/', 'http://').replace('https:/', 'https://').replace('file:/', 'file://'); | 27 | return url.toString().replaceAll('//', '/').replaceAll('http:/', 'http://').replaceAll('https:/', 'https://').replaceAll('file:/', 'file://'); |
28 | } | 28 | } |
29 | 29 | ||
30 | export function isValidFileUrl(path: string) { | 30 | export function isValidFileUrl(path: string) { |