From 5d3de435aebd81715b082f9c0373b0dce75fd87a Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Fri, 27 Jan 2023 08:30:24 -0400 Subject: [PATCH] fix isGoogleUrl (#1871) --- src/@utils/url/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/@utils/url/index.ts b/src/@utils/url/index.ts index 1c58f881b..313ccdbbf 100644 --- a/src/@utils/url/index.ts +++ b/src/@utils/url/index.ts @@ -1,3 +1,5 @@ +import isUrl from 'is-url-superb' + export function sanitizeUrl(url: string) { const u = decodeURI(url).trim().toLowerCase() const isAllowedUrlScheme = u.startsWith('http://') || u.startsWith('https://') @@ -6,7 +8,7 @@ export function sanitizeUrl(url: string) { // check if the url is a google domain export const isGoogleUrl = (url: string): boolean => { - if (!url) return + if (!url || !isUrl(url)) return const googleUrl = new URL(url) return googleUrl.hostname.endsWith('google.com') }