From 3d99041077acfdebe8683901c82a3afadb6eccd2 Mon Sep 17 00:00:00 2001 From: Mridul Verma Date: Tue, 24 Mar 2026 14:54:53 +0530 Subject: [PATCH] fix --- app/lib/methods/helpers/ensureSecureProtocol.test.ts | 4 ++++ app/lib/methods/helpers/ensureSecureProtocol.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/lib/methods/helpers/ensureSecureProtocol.test.ts b/app/lib/methods/helpers/ensureSecureProtocol.test.ts index a16873de649..327e378261e 100644 --- a/app/lib/methods/helpers/ensureSecureProtocol.test.ts +++ b/app/lib/methods/helpers/ensureSecureProtocol.test.ts @@ -17,6 +17,10 @@ describe('Add the protocol https at the begin of the URL', () => { const linkWithDoubleSlashAtBegin = '//www.google.com'; expect(ensureSecureProtocol(linkWithDoubleSlashAtBegin)).toBe('https://www.google.com'); }); + it('preserves double slashes that are part of the path', () => { + const linkWithDoubleSlashInPath = 'www.google.com/docs//api'; + expect(ensureSecureProtocol(linkWithDoubleSlashInPath)).toBe('https://www.google.com/docs//api'); + }); it('return the link as original when sent with rocketchat protocol', () => { const linkRocketChat = 'rocketchat://www.google.com'; expect(ensureSecureProtocol(linkRocketChat)).toBe(linkRocketChat); diff --git a/app/lib/methods/helpers/ensureSecureProtocol.ts b/app/lib/methods/helpers/ensureSecureProtocol.ts index 40d39acf737..6bb6044a7ce 100644 --- a/app/lib/methods/helpers/ensureSecureProtocol.ts +++ b/app/lib/methods/helpers/ensureSecureProtocol.ts @@ -3,7 +3,7 @@ const ensureSecureProtocol = (url: string): string => { // Check if URL has a protocol by looking for a valid URI scheme (RFC 3986) if (!url.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:/)) { - return `https://${url.replace('//', '')}`; + return `https://${url.replace(/^\/\//, '')}`; } return url; };