url.fileURLToPathBuffer(url[, options])


  • url <URL> | <string> 要转换为路径的文件网址字符串或网址对象。

    ¥url <URL> | <string> The file URL string or URL object to convert to a path.

  • options <Object>

    • windows <boolean> | <undefined> 如果 path 应作为 Windows 文件路径返回,则为 true;对于 posix,则返回 false;对于系统默认值,则返回 undefined。默认值:undefined

      ¥windows <boolean> | <undefined> true if the path should be return as a windows filepath, false for posix, and undefined for the system default. Default: undefined.

  • 返回:<Buffer> 已完全解析的特定于平台的 Node.js 文件路径作为 <Buffer>

    ¥Returns: <Buffer> The fully-resolved platform-specific Node.js file path as a <Buffer>.

url.fileURLToPath(...) 类似,不同之处在于它返回的不是路径的字符串表示形式,而是 Buffer。当输入 URL 包含不是有效 UTF-8/Unicode 序列的百分比编码段时,此转换非常有用。

¥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.