From b982937a42b9298a9ce3482db616615ea0cea9fd Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 28 Jul 2023 18:23:55 +0200 Subject: [PATCH] feat: add `isScriptProtocol` util (#156) --- src/utils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils.ts b/src/utils.ts index 3c8f7f93..cae821dd 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -43,6 +43,12 @@ export function hasProtocol( ); } +const PROTOCOL_SCRIPT_RE = /^(blob|data|javascript|vbscript):$/; + +export function isScriptProtocol(protocol?: string) { + return !!protocol && PROTOCOL_SCRIPT_RE.test(protocol); +} + const TRAILING_SLASH_RE = /\/$|\/\?/; export function hasTrailingSlash(input = "", queryParameters = false): boolean {