Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const {
Int8Array,
ObjectAssign,
ObjectKeys,
StringPrototypeCharCodeAt,
decodeURIComponent,
} = primordials;

Expand Down Expand Up @@ -103,8 +102,6 @@ const {
CHAR_ZERO_WIDTH_NOBREAK_SPACE,
CHAR_HASH,
CHAR_FORWARD_SLASH,
CHAR_LEFT_SQUARE_BRACKET,
CHAR_RIGHT_SQUARE_BRACKET,
CHAR_LEFT_ANGLE_BRACKET,
CHAR_RIGHT_ANGLE_BRACKET,
CHAR_LEFT_CURLY_BRACKET,
Expand Down Expand Up @@ -144,11 +141,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) {
}

function isIpv6Hostname(hostname) {
return (
StringPrototypeCharCodeAt(hostname, 0) === CHAR_LEFT_SQUARE_BRACKET &&
StringPrototypeCharCodeAt(hostname, hostname.length - 1) ===
CHAR_RIGHT_SQUARE_BRACKET
);
return hostname.startsWith('[') && hostname.endsWith(']');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the primordials? Are they not important?

CC @nodejs/primordials

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they definitely are

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How Is using startsWith and endsWith can be considered being faster as it claims that it has even better performance?

}

// This prevents some common spoofing bugs due to our use of IDNA toASCII. For
Expand Down