summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-06-20 17:26:14 +1000
committerGitHub <noreply@github.com>2024-06-20 17:26:14 +1000
commit28ee0a5bdd4f9681a964ae4648682396a2e10583 (patch)
tree68b08c0a365fa6a40ac8f29faba2d07f1fe5564e
parenta03c83383982372181c8d214c623a5fb176ee001 (diff)
fix(ext/node): use primordials in `ext/node/polyfills/_http_common.ts` (#24281)
-rw-r--r--ext/node/polyfills/_http_common.ts15
1 files changed, 7 insertions, 8 deletions
diff --git a/ext/node/polyfills/_http_common.ts b/ext/node/polyfills/_http_common.ts
index d4822960e..24dae6f30 100644
--- a/ext/node/polyfills/_http_common.ts
+++ b/ext/node/polyfills/_http_common.ts
@@ -1,20 +1,19 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
-// TODO(petamoriken): enable prefer-primordials for node polyfills
-// deno-lint-ignore-file prefer-primordials
-
-const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/;
+import { primordials } from "ext:core/mod.js";
+const { RegExpPrototypeTest, SafeRegExp } = primordials;
+const tokenRegExp = new SafeRegExp(/^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/);
/**
* Verifies that the given val is a valid HTTP token
* per the rules defined in RFC 7230
* See https://tools.ietf.org/html/rfc7230#section-3.2.6
*/
function checkIsHttpToken(val: string) {
- return tokenRegExp.test(val);
+ return RegExpPrototypeTest(tokenRegExp, val);
}
-const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
+const headerCharRegex = new SafeRegExp(/[^\t\x20-\x7e\x80-\xff]/);
/**
* True if val contains an invalid field-vchar
* field-value = *( field-content / obs-fold )
@@ -22,10 +21,10 @@ const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
* field-vchar = VCHAR / obs-text
*/
function checkInvalidHeaderChar(val: string) {
- return headerCharRegex.test(val);
+ return RegExpPrototypeTest(headerCharRegex, val);
}
-export const chunkExpression = /(?:^|\W)chunked(?:$|\W)/i;
+export const chunkExpression = new SafeRegExp(/(?:^|\W)chunked(?:$|\W)/i);
export {
checkInvalidHeaderChar as _checkInvalidHeaderChar,
checkIsHttpToken as _checkIsHttpToken,