docs(std/node/url): Added JSDocs for std/node/url (#7805)

This commit is contained in:
Bhumij Gupta 2020-11-06 06:58:00 +05:30 committed by GitHub
parent 6162807a7e
commit 2259e99aef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,6 +39,10 @@ const tabRegEx = /\t/g;
const _url = URL;
export { _url as URL };
/**
* Get fully resolved platform-specific file path from the given URL string/ object
* @param path The file URL string or URL object to convert to a path
*/
export function fileURLToPath(path: string | URL): string {
if (typeof path === "string") path = new URL(path);
else if (!(path instanceof URL)) {
@ -108,6 +112,7 @@ function getPathFromURLPosix(url: URL): string {
return decodeURIComponent(pathname);
}
/** Get fully resolved platform-specific File URL from the given file path */
export function pathToFileURL(filepath: string): URL {
let resolved = path.resolve(filepath);
// path.resolve strips trailing slashes so we must add them back