mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
refactor(ext/http): use String.prototype.trim()
instead of regex (#17722)
This commit is contained in:
parent
68008bee51
commit
cf06a7c7e6
1 changed files with 7 additions and 4 deletions
|
@ -51,6 +51,7 @@ const {
|
|||
StringPrototypeIncludes,
|
||||
StringPrototypeToLowerCase,
|
||||
StringPrototypeSplit,
|
||||
StringPrototypeTrim,
|
||||
Symbol,
|
||||
SymbolAsyncIterator,
|
||||
TypeError,
|
||||
|
@ -393,8 +394,9 @@ function upgradeWebSocket(request, options = {}) {
|
|||
const upgrade = request.headers.get("upgrade");
|
||||
const upgradeHasWebSocketOption = upgrade !== null &&
|
||||
ArrayPrototypeSome(
|
||||
StringPrototypeSplit(upgrade, /\s*,\s*/),
|
||||
(option) => StringPrototypeToLowerCase(option) === "websocket",
|
||||
StringPrototypeSplit(upgrade, ","),
|
||||
(option) =>
|
||||
StringPrototypeToLowerCase(StringPrototypeTrim(option)) === "websocket",
|
||||
);
|
||||
if (!upgradeHasWebSocketOption) {
|
||||
throw new TypeError(
|
||||
|
@ -405,8 +407,9 @@ function upgradeWebSocket(request, options = {}) {
|
|||
const connection = request.headers.get("connection");
|
||||
const connectionHasUpgradeOption = connection !== null &&
|
||||
ArrayPrototypeSome(
|
||||
StringPrototypeSplit(connection, /\s*,\s*/),
|
||||
(option) => StringPrototypeToLowerCase(option) === "upgrade",
|
||||
StringPrototypeSplit(connection, ","),
|
||||
(option) =>
|
||||
StringPrototypeToLowerCase(StringPrototypeTrim(option)) === "upgrade",
|
||||
);
|
||||
if (!connectionHasUpgradeOption) {
|
||||
throw new TypeError(
|
||||
|
|
Loading…
Add table
Reference in a new issue