market/src/@utils/url/index.ts

6 lines
224 B
TypeScript

export function sanitizeUrl(url: string) {
const u = decodeURI(url).trim().toLowerCase()
const isAllowedUrlScheme = u.startsWith('http://') || u.startsWith('https://')
return isAllowedUrlScheme ? url : 'about:blank'
}