File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
ext/node/polyfills/internal Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 11// Copyright 2018-2025 the Deno authors. MIT license.
22
3- // TODO(petamoriken): enable prefer-primordials for node polyfills
4- // deno-lint-ignore-file prefer-primordials
5-
63import { fileURLToPath } from "node:url" ;
74import { Buffer } from "node:buffer" ;
5+ import { primordials } from "ext:core/mod.js" ;
6+ const {
7+ Number,
8+ ObjectPrototypeIsPrototypeOf,
9+ StringPrototypeSlice,
10+ StringPrototypeStartsWith,
11+ Symbol,
12+ decodeURIComponent,
13+ } = primordials ;
814
915const searchParams = Symbol ( "query" ) ;
1016
1117export function toPathIfFileURL (
1218 fileURLOrPath : string | Buffer | URL ,
1319) : string | Buffer {
14- if ( ! ( fileURLOrPath instanceof URL ) ) {
20+ if ( ! ( ObjectPrototypeIsPrototypeOf ( URL . prototype , fileURLOrPath ) ) ) {
1521 return fileURLOrPath ;
1622 }
1723 return fileURLToPath ( fileURLOrPath ) ;
@@ -26,8 +32,8 @@ export function urlToHttpOptions(url: any): any {
2632 const options : any = {
2733 protocol : url . protocol ,
2834 hostname : typeof url . hostname === "string" &&
29- url . hostname . startsWith ( "[" )
30- ? url . hostname . slice ( 1 , - 1 )
35+ StringPrototypeStartsWith ( url . hostname , "[" )
36+ ? StringPrototypeSlice ( url . hostname , 1 , - 1 )
3137 : url . hostname ,
3238 hash : url . hash ,
3339 search : url . search ,
You can’t perform that action at this time.
0 commit comments