1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

fix isGoogleUrl (#1871)

This commit is contained in:
EnzoVezzaro 2023-01-27 08:30:24 -04:00 committed by GitHub
parent b2fa5dc538
commit 5d3de435ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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')
}