summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/path
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/path')
-rw-r--r--ext/node/polyfills/path/_posix.ts21
-rw-r--r--ext/node/polyfills/path/_util.ts15
-rw-r--r--ext/node/polyfills/path/_win32.ts30
-rw-r--r--ext/node/polyfills/path/mod.ts1
-rw-r--r--ext/node/polyfills/path/posix.ts1
-rw-r--r--ext/node/polyfills/path/win32.ts1
6 files changed, 0 insertions, 69 deletions
diff --git a/ext/node/polyfills/path/_posix.ts b/ext/node/polyfills/path/_posix.ts
index 7190795a3..29fecf131 100644
--- a/ext/node/polyfills/path/_posix.ts
+++ b/ext/node/polyfills/path/_posix.ts
@@ -12,7 +12,6 @@ import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
import {
_format,
assertPath,
- encodeWhitespace,
isPosixPathSeparator,
normalizeString,
} from "ext:deno_node/path/_util.ts";
@@ -476,25 +475,6 @@ export function parse(path: string): ParsedPath {
return ret;
}
-
-/**
- * Converts a path string to a file URL.
- *
- * ```ts
- * toFileUrl("/home/foo"); // new URL("file:///home/foo")
- * ```
- * @param path to convert to file URL
- */
-export function toFileUrl(path: string): URL {
- if (!isAbsolute(path)) {
- throw new TypeError("Must be an absolute path.");
- }
- const url = new URL("file:///");
- url.pathname = encodeWhitespace(
- path.replace(/%/g, "%25").replace(/\\/g, "%5C"),
- );
- return url;
-}
export default {
basename,
delimiter,
@@ -508,6 +488,5 @@ export default {
relative,
resolve,
sep,
- toFileUrl,
toNamespacedPath,
};
diff --git a/ext/node/polyfills/path/_util.ts b/ext/node/polyfills/path/_util.ts
index ea2afd873..fcf32d55c 100644
--- a/ext/node/polyfills/path/_util.ts
+++ b/ext/node/polyfills/path/_util.ts
@@ -114,18 +114,3 @@ export function _format(
if (dir === pathObject.root) return dir + base;
return dir + sep + base;
}
-
-const WHITESPACE_ENCODINGS: Record<string, string> = {
- "\u0009": "%09",
- "\u000A": "%0A",
- "\u000B": "%0B",
- "\u000C": "%0C",
- "\u000D": "%0D",
- "\u0020": "%20",
-};
-
-export function encodeWhitespace(string: string): string {
- return string.replaceAll(/[\s]/g, (c) => {
- return WHITESPACE_ENCODINGS[c] ?? c;
- });
-}
diff --git a/ext/node/polyfills/path/_win32.ts b/ext/node/polyfills/path/_win32.ts
index 856ffdff5..dccd00d3c 100644
--- a/ext/node/polyfills/path/_win32.ts
+++ b/ext/node/polyfills/path/_win32.ts
@@ -17,7 +17,6 @@ import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
import {
_format,
assertPath,
- encodeWhitespace,
isPathSeparator,
isWindowsDeviceRoot,
normalizeString,
@@ -951,34 +950,6 @@ export function parse(path: string): ParsedPath {
return ret;
}
-/**
- * Converts a path string to a file URL.
- *
- * ```ts
- * toFileUrl("\\home\\foo"); // new URL("file:///home/foo")
- * toFileUrl("C:\\Users\\foo"); // new URL("file:///C:/Users/foo")
- * toFileUrl("\\\\127.0.0.1\\home\\foo"); // new URL("file://127.0.0.1/home/foo")
- * ```
- * @param path to convert to file URL
- */
-export function toFileUrl(path: string): URL {
- if (!isAbsolute(path)) {
- throw new TypeError("Must be an absolute path.");
- }
- const [, hostname, pathname] = path.match(
- /^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/,
- )!;
- const url = new URL("file:///");
- url.pathname = encodeWhitespace(pathname.replace(/%/g, "%25"));
- if (hostname != null && hostname != "localhost") {
- url.hostname = hostname;
- if (!url.hostname) {
- throw new TypeError("Invalid hostname.");
- }
- }
- return url;
-}
-
export default {
basename,
delimiter,
@@ -992,6 +963,5 @@ export default {
relative,
resolve,
sep,
- toFileUrl,
toNamespacedPath,
};
diff --git a/ext/node/polyfills/path/mod.ts b/ext/node/polyfills/path/mod.ts
index 92611d502..f0f431d2b 100644
--- a/ext/node/polyfills/path/mod.ts
+++ b/ext/node/polyfills/path/mod.ts
@@ -35,7 +35,6 @@ export const {
relative,
resolve,
sep,
- toFileUrl,
toNamespacedPath,
} = path;
export default path;
diff --git a/ext/node/polyfills/path/posix.ts b/ext/node/polyfills/path/posix.ts
index 17e890085..12c4946b1 100644
--- a/ext/node/polyfills/path/posix.ts
+++ b/ext/node/polyfills/path/posix.ts
@@ -17,7 +17,6 @@ export const {
relative,
resolve,
sep,
- toFileUrl,
toNamespacedPath,
} = path.posix;
diff --git a/ext/node/polyfills/path/win32.ts b/ext/node/polyfills/path/win32.ts
index b015c0eba..b595c11eb 100644
--- a/ext/node/polyfills/path/win32.ts
+++ b/ext/node/polyfills/path/win32.ts
@@ -17,7 +17,6 @@ export const {
relative,
resolve,
sep,
- toFileUrl,
toNamespacedPath,
} = path.win32;