diff options
Diffstat (limited to 'cli/js/web/util.ts')
-rw-r--r-- | cli/js/web/util.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/js/web/util.ts b/cli/js/web/util.ts index 0ab367554..53ff8ef22 100644 --- a/cli/js/web/util.ts +++ b/cli/js/web/util.ts @@ -189,3 +189,22 @@ export function defineEnumerableProps( Reflect.defineProperty(Ctor.prototype, prop, { enumerable: true }); } } + +// @internal +export function getHeaderValueParams(value: string): Map<string, string> { + const params = new Map(); + // Forced to do so for some Map constructor param mismatch + value + .split(";") + .slice(1) + .map((s): string[] => s.trim().split("=")) + .filter((arr): boolean => arr.length > 1) + .map(([k, v]): [string, string] => [k, v.replace(/^"([^"]*)"$/, "$1")]) + .forEach(([k, v]): Map<string, string> => params.set(k, v)); + return params; +} + +// @internal +export function hasHeaderValueOf(s: string, value: string): boolean { + return new RegExp(`^${value}[\t\s]*;?`).test(s); +} |