summaryrefslogtreecommitdiff
path: root/cli/js/web/fetch.ts
diff options
context:
space:
mode:
authorMarcos Casagrande <marcoscvp90@gmail.com>2020-05-25 15:12:09 +0200
committerGitHub <noreply@github.com>2020-05-25 09:12:09 -0400
commit20bf04dc7e046e8191443e75be451ec81523a86a (patch)
treea3d31062a8fa91dc12730fa521314a86a73affb7 /cli/js/web/fetch.ts
parent131f2a5f0cdcdbebe3e17c447869f92c99a7c051 (diff)
Move getHeaderValueParams & hasHeaderValueOf to util.ts (#5824)
Diffstat (limited to 'cli/js/web/fetch.ts')
-rw-r--r--cli/js/web/fetch.ts18
1 files changed, 1 insertions, 17 deletions
diff --git a/cli/js/web/fetch.ts b/cli/js/web/fetch.ts
index 38ca03aca..3485a770a 100644
--- a/cli/js/web/fetch.ts
+++ b/cli/js/web/fetch.ts
@@ -10,23 +10,7 @@ import { close } from "../ops/resources.ts";
import { Buffer } from "../buffer.ts";
import { fetch as opFetch, FetchResponse } from "../ops/fetch.ts";
import { DomFileImpl } from "./dom_file.ts";
-
-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;
-}
-
-function hasHeaderValueOf(s: string, value: string): boolean {
- return new RegExp(`^${value}[\t\s]*;?`).test(s);
-}
+import { getHeaderValueParams, hasHeaderValueOf } from "./util.ts";
class Body
implements domTypes.Body, ReadableStream<Uint8Array>, io.Reader, io.Closer {