function
url.fileURLToPathBuffer
Like url.fileURLToPath(...) except that instead of returning a string representation of the path, a Buffer is returned. This conversion is helpful when the input URL contains percent-encoded segments that are not valid UTF-8 / Unicode sequences.
Security Considerations:
This function has the same security considerations as url.fileURLToPath(). It decodes percent-encoded characters, including encoded dot-segments (%2e as . and %2e%2e as ..), and normalizes the path. Applications must not rely on this function alone to prevent directory traversal attacks. Always perform explicit path validation on the returned buffer value before using it for file system operations.
The file URL string or URL object to convert to a path.
The fully-resolved platform-specific Node.js file path as a Buffer.
Referenced types
interface FileUrlToPathOptions
- windows?: boolean
trueif thepathshould be return as a windows filepath,falsefor posix, andundefinedfor the system default.