Skip to content

Commit

Permalink
fix: use non-symbols in isURLInstance check
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Aug 4, 2020
1 parent f53aac9 commit 07e9564
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions patches/node/.patches
Expand Up @@ -40,3 +40,4 @@ update_tests_after_increasing_typed_array_size.patch
darwin_work_around_clock_jumping_back_in_time.patch
fix_do_not_register_the_esm_loader_in_renderer_processes.patch
fix_allow_preventing_setpromiserejectcallback.patch
lib_use_non-symbols_in_isurlinstance_check.patch
30 changes: 30 additions & 0 deletions patches/node/lib_use_non-symbols_in_isurlinstance_check.patch
@@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Tue, 4 Aug 2020 09:17:06 -0700
Subject: lib: use non-symbols in isURLInstance check

This slightly changes the conditional used to determine whether or
not something is a URL instance. Since Node.js adds symbols to the URL
not specified by the WHATWG, those symbols are not present in other
implementations (like Blink's) and therefore can cause false negatives.

This fixes that by slightly changing the check to properties present
in all URL instances as specified in the WHATWG spec.

Upstreamed at: https://github.com/nodejs/node/pull/34622.

diff --git a/lib/internal/url.js b/lib/internal/url.js
index 78f5b32745a0436337233e8a4b57b89263effad6..ace274501f2c1f6bb06f600abb850e737c988338 100644
--- a/lib/internal/url.js
+++ b/lib/internal/url.js
@@ -1394,8 +1394,8 @@ function pathToFileURL(filepath) {
}

function isURLInstance(fileURLOrPath) {
- return fileURLOrPath != null && fileURLOrPath[searchParams] &&
- fileURLOrPath[searchParams][searchParams];
+ return fileURLOrPath != null && fileURLOrPath['href'] &&
+ fileURLOrPath['origin'];
}

function toPathIfFileURL(fileURLOrPath) {

0 comments on commit 07e9564

Please sign in to comment.