aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers
diff options
context:
space:
mode:
authorLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-05-14 22:36:26 -0500
committerLibravatar GitHub <noreply@github.com>2022-05-15 03:36:26 +0000
commitf4fd7dcfe7b84e54999062325a268d786975ab12 (patch)
tree16da4ff6baf742c3bbd50488737d130e9a1c8795 /src/helpers
parent6.0.0-nightly.35 [skip ci] (diff)
downloadferdium-app-f4fd7dcfe7b84e54999062325a268d786975ab12.tar.gz
ferdium-app-f4fd7dcfe7b84e54999062325a268d786975ab12.tar.zst
ferdium-app-f4fd7dcfe7b84e54999062325a268d786975ab12.zip
Fix issue where the replacement of double-slash was over-aggressive (#151)
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/url-helpers.test.ts3
-rw-r--r--src/helpers/url-helpers.ts2
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
26export function fixUrl(url: string | URL) { 26export 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
30export function isValidFileUrl(path: string) { 30export function isValidFileUrl(path: string) {