| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,6 @@ const { | |||
| 7 | 7 | RegExpPrototypeExec, | |
| 8 | 8 | StringPrototypeIndexOf, | |
| 9 | 9 | StringPrototypeSlice, | |
| 10 | - StringPrototypeStartsWith, | ||
| 11 | 10 | } = primordials; | |
| 12 | 11 | const { | |
| 13 | 12 | fileURLToPath, | |
@@ -285,22 +284,14 @@ function findPackageJSON(specifier, base = 'data:') { | |||
| 285 | 284 | validateString(specifier, 'specifier'); | |
| 286 | 285 | } | |
| 287 | 286 | ||
| 288 | - let parentURL; | ||
| 289 | - if (isURL(base)) { | ||
| 290 | - parentURL = new URL(base); | ||
| 291 | - } else { | ||
| 287 | + let parentURL = base; | ||
| 288 | + if (!isURL(base)) { | ||
| 292 | 289 | validateString(base, 'base'); | |
| 293 | - if ( | ||
| 294 | - path.isAbsolute(base) || | ||
| 295 | - (URLCanParse(base) && !StringPrototypeStartsWith(base, 'file:')) | ||
| 296 | - ) { | ||
| 297 | - parentURL = pathToFileURL(path.toNamespacedPath(base)); | ||
| 298 | - } else { | ||
| 299 | - parentURL = URL.parse(base) || pathToFileURL(base); | ||
| 300 | - } | ||
| 290 | + parentURL = path.isAbsolute(base) ? pathToFileURL(base) : new URL(base); | ||
| 301 | 291 | } | |
| 302 | 292 | ||
| 303 | 293 | if (specifier && specifier[0] !== '.' && specifier[0] !== '/' && !URLCanParse(specifier)) { | |
| 294 | + // If `specifier` is a bare specifier. | ||
| 304 | 295 | const { packageJSONPath } = getPackageJSONURL(specifier, parentURL); | |
| 305 | 296 | return packageJSONPath; | |
| 306 | 297 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments