Convert a filesystem path to a file:// URL.
Bun.pathToFileURL function | API Reference | Bun BuildDocsReferenceGuidesBlogDiscord/Bun/pathToFileURLFpathToFileURL BuildDocsReferenceGuidesBlogDiscord /Bun/pathToFileURLFpathToFileURL pathToFileURLfunction pathToFileURL(path: string): URL; @param path @returns Referenced typesclass URL hash: string host: string hostname: string href: string readonly origin: string password: string pathname: string port: string protocol: string search: string readonly searchParams: URLSearchParams username: string toJSON(): string; toString(): string;static canParse(url: string | URL,base?: string | URL): boolean; static createObjectURL(obj: Blob | MediaSource): string; static parse(url: string | URL,base?: string | URL): null | URL; static revokeObjectURL(url: string): void;
Search the reference...
/
function
The path to convert.
A URL with the file:// scheme.
const url = Bun.pathToFileURL("/foo/bar.txt");
console.log(url.href); // "file:http:///foo/bar.txt"
Internally, this function uses WebKit's URL API to convert the path to a file:// URL.
The URL interface represents an object providing static methods used for creating object URLs.
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlogToolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →Bun.pathToFileURL function | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引
- API documentation for function bun.pathToFileURL | Bun