Skip to content

Function: toFileUrl()

ts
function toFileUrl(path): string;

将路径转换为 file:// URL。

Parameters

ParameterTypeDescription
pathstring要转换的路径

Returns

string

file:// URL 字符串

Example

ts
toFileUrl('/foo/bar')              // => 'file:///foo/bar'
toFileUrl('C:\\temp\\foo.txt')     // => 'file:///C:/temp/foo.txt'
toFileUrl('//host/share/file.txt') // => 'file://host/share/file.txt'

Since

1.0.0

Released under the MIT License.