From 44c5193ab8b25422ae5cb679ce788a8c636108ac Mon Sep 17 00:00:00 2001 From: Vijay A Date: Thu, 25 May 2023 13:04:39 +0530 Subject: Minor refactoring to remove code duplication --- src/helpers/url-helpers.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/helpers') diff --git a/src/helpers/url-helpers.ts b/src/helpers/url-helpers.ts index 9c5cf7752..795d3f2cb 100644 --- a/src/helpers/url-helpers.ts +++ b/src/helpers/url-helpers.ts @@ -2,6 +2,7 @@ import { URL } from 'url'; import { ensureDirSync, existsSync } from 'fs-extra'; import { shell } from 'electron'; +import normalizeUrl from 'normalize-url'; import { ALLOWED_PROTOCOLS } from '../config'; const debug = require('../preload-safe-debug')('Ferdium:Helpers:url'); @@ -49,3 +50,11 @@ export function openExternalUrl( shell.openExternal(fixedUrl.toString()); } } + +export function normalizedUrl(url: string) { + return normalizeUrl(url, { + stripAuthentication: false, + stripWWW: false, + removeTrailingSlash: false, + }); +} -- cgit v1.2.3-54-g00ecf