(url)
| 1598 | } |
| 1599 | |
| 1600 | function getPathBufferFromURLPosix(url) { |
| 1601 | if (url.hostname !== '') { |
| 1602 | throw new ERR_INVALID_FILE_URL_HOST(platform); |
| 1603 | } |
| 1604 | const pathname = url.pathname; |
| 1605 | |
| 1606 | // In the getPathFromURLPosix variant, we scan the input for forward slash |
| 1607 | // (/) characters, specifically looking for the ASCII/UTF8 and forbidding |
| 1608 | // its use. This is a bit tricky because these may conflict with non-UTF8 |
| 1609 | // encodings. Passing in an encoding option does not help since our Buffer |
| 1610 | // encoding only knows about certain specific text encodings and a single |
| 1611 | // file path might actually contain segments that use multiple encodings. |
| 1612 | // It's tricky! So, for this variation where we are producing a buffer, we |
| 1613 | // won't scan for the slashes at all, and instead will decode the bytes |
| 1614 | // literally into the returned Buffer. We're going to do the best we can and |
| 1615 | // just interpret the input url as a sequence of bytes. |
| 1616 | const u8 = percentDecode(Buffer.from(pathname, 'utf8')); |
| 1617 | return Buffer.from(TypedArrayPrototypeGetBuffer(u8), |
| 1618 | TypedArrayPrototypeGetByteOffset(u8), |
| 1619 | TypedArrayPrototypeGetByteLength(u8)); |
| 1620 | } |
| 1621 | |
| 1622 | function fileURLToPath(path, options = kEmptyObject) { |
| 1623 | const windows = options?.windows; |
no test coverage detected