@@ -67,12 +67,15 @@ example, `path.resolve('C:\\')` can potentially return a different result than
67
67
<!-- YAML
68
68
added: v0.1.25
69
69
changes:
70
+ - version: REPLACEME
71
+ pr-url: https://github.com/nodejs/node/pull/52672
72
+ description: Passing a file URL as an argument is now supported.
70
73
- version: v6.0.0
71
74
pr-url: https://github.com/nodejs/node/pull/5348
72
75
description: Passing a non-string as the `path` argument will throw now.
73
76
-->
74
77
75
- * ` path ` {string}
78
+ * ` path ` {string|URL }
76
79
* ` suffix ` {string} An optional suffix to remove
77
80
* Returns: {string}
78
81
@@ -101,8 +104,8 @@ path.win32.basename('C:\\foo.HTML', '.html');
101
104
// Returns: 'foo.HTML'
102
105
```
103
106
104
- A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string or if ` suffix ` is given
105
- and is not a string.
107
+ A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string or an instance of [ ` URL ` ] [ ] ,
108
+ or if ` suffix ` is given and is not a string.
106
109
107
110
## ` path.delimiter `
108
111
@@ -142,12 +145,15 @@ process.env.PATH.split(path.delimiter);
142
145
<!-- YAML
143
146
added: v0.1.16
144
147
changes:
148
+ - version: REPLACEME
149
+ pr-url: https://github.com/nodejs/node/pull/52672
150
+ description: Passing a file URL as an argument is now supported.
145
151
- version: v6.0.0
146
152
pr-url: https://github.com/nodejs/node/pull/5348
147
153
description: Passing a non-string as the `path` argument will throw now.
148
154
-->
149
155
150
- * ` path ` {string}
156
+ * ` path ` {string|URL }
151
157
* Returns: {string}
152
158
153
159
The ` path.dirname() ` method returns the directory name of a ` path ` , similar to
@@ -159,19 +165,22 @@ path.dirname('/foo/bar/baz/asdf/quux');
159
165
// Returns: '/foo/bar/baz/asdf'
160
166
```
161
167
162
- A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string.
168
+ A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string or an instance of [ ` URL ` ] [ ]
163
169
164
170
## ` path.extname(path) `
165
171
166
172
<!-- YAML
167
173
added: v0.1.25
168
174
changes:
175
+ - version: REPLACEME
176
+ pr-url: https://github.com/nodejs/node/pull/52672
177
+ description: Passing a file URL as an argument is now supported.
169
178
- version: v6.0.0
170
179
pr-url: https://github.com/nodejs/node/pull/5348
171
180
description: Passing a non-string as the `path` argument will throw now.
172
181
-->
173
182
174
- * ` path ` {string}
183
+ * ` path ` {string|URL }
175
184
* Returns: {string}
176
185
177
186
The ` path.extname() ` method returns the extension of the ` path ` , from the last
@@ -200,7 +209,7 @@ path.extname('.index.md');
200
209
// Returns: '.md'
201
210
```
202
211
203
- A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string.
212
+ A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string or an instance of [ ` URL ` ] [ ] .
204
213
205
214
## ` path.format(pathObject) `
206
215
@@ -283,9 +292,13 @@ path.format({
283
292
284
293
<!-- YAML
285
294
added: v0.11.2
295
+ changes:
296
+ - version: REPLACEME
297
+ pr-url: https://github.com/nodejs/node/pull/52672
298
+ description: Passing a file URL as an argument is now supported.
286
299
-->
287
300
288
- * ` path ` {string}
301
+ * ` path ` {string|URL }
289
302
* Returns: {boolean}
290
303
291
304
The ` path.isAbsolute() ` method determines if ` path ` is an absolute path.
@@ -313,15 +326,19 @@ path.isAbsolute('bar/baz'); // false
313
326
path .isAbsolute (' .' ); // false
314
327
```
315
328
316
- A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string.
329
+ A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string or an instance of [ ` URL ` ] [ ] .
317
330
318
331
## ` path.join([...paths]) `
319
332
320
333
<!-- YAML
321
334
added: v0.1.16
335
+ changes:
336
+ - version: REPLACEME
337
+ pr-url: https://github.com/nodejs/node/pull/52672
338
+ description: Passing a file URL as an argument is now supported.
322
339
-->
323
340
324
- * ` ...paths ` {string} A sequence of path segments
341
+ * ` ...paths ` {string|URL } A sequence of path segments
325
342
* Returns: {string}
326
343
327
344
The ` path.join() ` method joins all given ` path ` segments together using the
@@ -339,15 +356,19 @@ path.join('foo', {}, 'bar');
339
356
// Throws 'TypeError: Path must be a string. Received {}'
340
357
```
341
358
342
- A [ ` TypeError ` ] [ ] is thrown if any of the path segments is not a string.
359
+ A [ ` TypeError ` ] [ ] is thrown if any of the path segments is not a string or an instance of [ ` URL ` ] [ ] .
343
360
344
361
## ` path.normalize(path) `
345
362
346
363
<!-- YAML
347
364
added: v0.1.23
365
+ changes:
366
+ - version: REPLACEME
367
+ pr-url: https://github.com/nodejs/node/pull/52672
368
+ description: Passing a file URL as an argument is now supported.
348
369
-->
349
370
350
- * ` path ` {string}
371
+ * ` path ` {string|URL }
351
372
* Returns: {string}
352
373
353
374
The ` path.normalize() ` method normalizes the given ` path ` , resolving ` '..' ` and
@@ -391,15 +412,19 @@ path.win32.normalize('C:////temp\\\\/\\/\\/foo/bar');
391
412
// Returns: 'C:\\temp\\foo\\bar'
392
413
```
393
414
394
- A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string.
415
+ A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string or an instance of [ ` URL ` ] [ ] .
395
416
396
417
## ` path.parse(path) `
397
418
398
419
<!-- YAML
399
420
added: v0.11.15
421
+ changes:
422
+ - version: REPLACEME
423
+ pr-url: https://github.com/nodejs/node/pull/52672
424
+ description: Passing a file URL as an argument is now supported.
400
425
-->
401
426
402
- * ` path ` {string}
427
+ * ` path ` {string|URL }
403
428
* Returns: {Object}
404
429
405
430
The ` path.parse() ` method returns an object whose properties represent
@@ -458,7 +483,7 @@ path.parse('C:\\path\\dir\\file.txt');
458
483
(All spaces in the "" line should be ignored. They are purely for formatting.)
459
484
```
460
485
461
- A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string.
486
+ A [ ` TypeError ` ] [ ] is thrown if ` path ` is not a string or an instance of [ ` URL ` ] [ ] .
462
487
463
488
## ` path.posix `
464
489
@@ -482,14 +507,17 @@ The API is accessible via `require('node:path').posix` or `require('node:path/po
482
507
<!-- YAML
483
508
added: v0.5.0
484
509
changes:
510
+ - version: REPLACEME
511
+ pr-url: https://github.com/nodejs/node/pull/52672
512
+ description: Passing a file URL as an argument is now supported.
485
513
- version: v6.8.0
486
514
pr-url: https://github.com/nodejs/node/pull/8523
487
515
description: On Windows, the leading slashes for UNC paths are now included
488
516
in the return value.
489
517
-->
490
518
491
- * ` from ` {string}
492
- * ` to ` {string}
519
+ * ` from ` {string|URL }
520
+ * ` to ` {string|URL }
493
521
* Returns: {string}
494
522
495
523
The ` path.relative() ` method returns the relative path from ` from ` to ` to ` based
@@ -513,15 +541,19 @@ path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb');
513
541
// Returns: '..\\..\\impl\\bbb'
514
542
```
515
543
516
- A [ ` TypeError ` ] [ ] is thrown if either ` from ` or ` to ` is not a string.
544
+ A [ ` TypeError ` ] [ ] is thrown if either ` from ` or ` to ` is not a string or an instance of [ ` URL ` ] [ ] .
517
545
518
546
## ` path.resolve([...paths]) `
519
547
520
548
<!-- YAML
521
549
added: v0.3.4
550
+ changes:
551
+ - version: REPLACEME
552
+ pr-url: https://github.com/nodejs/node/pull/52672
553
+ description: Passing a file URL as an argument is now supported.
522
554
-->
523
555
524
- * ` ...paths ` {string} A sequence of paths or path segments
556
+ * ` ...paths ` {string|URL } A sequence of paths or path segments
525
557
* Returns: {string}
526
558
527
559
The ` path.resolve() ` method resolves a sequence of paths or path segments into
@@ -556,7 +588,7 @@ path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif');
556
588
// this returns '/home/myself/node/wwwroot/static_files/gif/image.gif'
557
589
```
558
590
559
- A [ ` TypeError ` ] [ ] is thrown if any of the arguments is not a string.
591
+ A [ ` TypeError ` ] [ ] is thrown if any of the arguments is not a string or an instance of [ ` URL ` ] [ ] .
560
592
561
593
## ` path.sep `
562
594
@@ -593,14 +625,18 @@ slashes (`\`).
593
625
594
626
<!-- YAML
595
627
added: v9.0.0
628
+ changes:
629
+ - version: REPLACEME
630
+ pr-url: https://github.com/nodejs/node/pull/52672
631
+ description: Passing a file URL as an argument is now supported.
596
632
-->
597
633
598
- * ` path ` {string}
634
+ * ` path ` {string|URL }
599
635
* Returns: {string}
600
636
601
637
On Windows systems only, returns an equivalent [ namespace-prefixed path] [ ] for
602
- the given ` path ` . If ` path ` is not a string, ` path ` will be returned without
603
- modifications.
638
+ the given ` path ` . If ` path ` is not a string or URL , ` path ` will be returned
639
+ without modifications.
604
640
605
641
This method is meaningful only on Windows systems. On POSIX systems, the
606
642
method is non-operational and always returns ` path ` without modifications.
@@ -624,6 +660,7 @@ The API is accessible via `require('node:path').win32` or `require('node:path/wi
624
660
625
661
[ MSDN-Rel-Path ] : https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#fully-qualified-vs-relative-paths
626
662
[ `TypeError` ] : errors.md#class-typeerror
663
+ [ `URL` ] : url.md#the-whatwg-url-api
627
664
[ `path.parse()` ] : #pathparsepath
628
665
[ `path.posix` ] : #pathposix
629
666
[ `path.sep` ] : #pathsep
0 commit comments