@jsenv/urls 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/main_node.js +3 -3
- package/src/main_shared.js +22 -22
- package/src/{file_and_path → node}/caller_position.js +1 -1
- package/src/{file_and_path → node}/filesystem_path_to_url.js +1 -1
- package/src/{file_and_path → shared}/resolve_directory_url.js +1 -1
- package/src/{composition → shared}/set_url_part.js +27 -23
- package/src/{file_and_path/url_is_inside_of.js → shared/url_is_or_is_inside_of.js} +2 -2
- package/src/{url_to_relative_url.js → shared/url_to_relative_url.js} +1 -1
- package/src/{file_and_path → shared}/yield_ancestor_urls.js +1 -1
- /package/src/{file_and_path → node}/url_to_filesystem_path.js +0 -0
- /package/src/{composition → shared}/common_pathname.js +0 -0
- /package/src/{data_url.js → shared/data_url.js} +0 -0
- /package/src/{ensure_url_trailing_slash.js → shared/ensure_url_trailing_slash.js} +0 -0
- /package/src/{file_and_path → shared}/is_filesystem_path.js +0 -0
- /package/src/{move_url.js → shared/move_url.js} +0 -0
- /package/src/{composition → shared}/pathname_to_extension.js +0 -0
- /package/src/{query_params → shared}/query_params.js +0 -0
- /package/src/{file_and_path → shared}/resolve_url.js +0 -0
- /package/src/{composition → shared}/resource_to_parts.js +0 -0
- /package/src/{composition → shared}/url_to_basename.js +0 -0
- /package/src/{composition → shared}/url_to_extension.js +0 -0
- /package/src/{composition → shared}/url_to_filename.js +0 -0
- /package/src/{composition → shared}/url_to_origin.js +0 -0
- /package/src/{composition → shared}/url_to_parent_url.js +0 -0
- /package/src/{composition → shared}/url_to_pathname.js +0 -0
- /package/src/{composition → shared}/url_to_resource.js +0 -0
- /package/src/{composition → shared}/url_to_scheme.js +0 -0
- /package/src/{url_trace.js → shared/url_trace.js} +0 -0
- /package/src/{file_and_path → shared}/windows_file_path_utils.js +0 -0
package/package.json
CHANGED
package/src/main_node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getCallerPosition } from "./file_and_path/caller_position.js";
|
|
2
|
-
export { fileSystemPathToUrl } from "./file_and_path/filesystem_path_to_url.js";
|
|
3
|
-
export { urlToFileSystemPath } from "./file_and_path/url_to_filesystem_path.js";
|
|
4
1
|
export * from "./main_shared.js";
|
|
2
|
+
export { getCallerPosition } from "./node/caller_position.js";
|
|
3
|
+
export { fileSystemPathToUrl } from "./node/filesystem_path_to_url.js";
|
|
4
|
+
export { urlToFileSystemPath } from "./node/url_to_filesystem_path.js";
|
package/src/main_shared.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// tslint:disable:ordered-imports
|
|
2
2
|
|
|
3
|
-
export { DATA_URL } from "./data_url.js";
|
|
4
|
-
export { stringifyUrlSite } from "./url_trace.js";
|
|
3
|
+
export { DATA_URL } from "./shared/data_url.js";
|
|
4
|
+
export { stringifyUrlSite } from "./shared/url_trace.js";
|
|
5
5
|
export {
|
|
6
6
|
setUrlFilename,
|
|
7
7
|
setUrlBasename,
|
|
@@ -9,7 +9,7 @@ export {
|
|
|
9
9
|
ensurePathnameTrailingSlash,
|
|
10
10
|
removePathnameTrailingSlash,
|
|
11
11
|
asUrlUntilPathname,
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./shared/set_url_part.js";
|
|
13
13
|
export {
|
|
14
14
|
asUrlWithoutSearch,
|
|
15
15
|
asSpecifierWithoutSearch,
|
|
@@ -20,32 +20,32 @@ export {
|
|
|
20
20
|
injectQueryParamWithoutEncoding,
|
|
21
21
|
injectQueryParamIntoSpecifierWithoutEncoding,
|
|
22
22
|
renderUrlOrRelativeUrlFilename,
|
|
23
|
-
} from "./
|
|
23
|
+
} from "./shared/query_params.js";
|
|
24
|
+
export { moveUrl } from "./shared/move_url.js";
|
|
25
|
+
export { urlToRelativeUrl } from "./shared/url_to_relative_url.js";
|
|
24
26
|
// composition
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export { urlToScheme } from "./composition/url_to_scheme.js";
|
|
35
|
-
export { getCommonPathname } from "./composition/common_pathname.js";
|
|
27
|
+
export { urlToBasename } from "./shared/url_to_basename.js";
|
|
28
|
+
export { urlToExtension } from "./shared/url_to_extension.js";
|
|
29
|
+
export { urlToFilename } from "./shared/url_to_filename.js";
|
|
30
|
+
export { urlToOrigin } from "./shared/url_to_origin.js";
|
|
31
|
+
export { urlToParentUrl } from "./shared/url_to_parent_url.js";
|
|
32
|
+
export { urlToPathname } from "./shared/url_to_pathname.js";
|
|
33
|
+
export { urlToResource } from "./shared/url_to_resource.js";
|
|
34
|
+
export { urlToScheme } from "./shared/url_to_scheme.js";
|
|
35
|
+
export { getCommonPathname } from "./shared/common_pathname.js";
|
|
36
36
|
export {
|
|
37
37
|
resourceToParts,
|
|
38
38
|
resourceToPathname,
|
|
39
39
|
resourceToExtension,
|
|
40
|
-
} from "./
|
|
40
|
+
} from "./shared/resource_to_parts.js";
|
|
41
41
|
// file_and_path
|
|
42
42
|
export {
|
|
43
43
|
startsWithWindowsDriveLetter,
|
|
44
44
|
windowsFilePathToUrl,
|
|
45
45
|
replaceBackSlashesWithSlashes,
|
|
46
|
-
} from "./
|
|
47
|
-
export { isFileSystemPath } from "./
|
|
48
|
-
export { resolveUrl } from "./
|
|
49
|
-
export { resolveDirectoryUrl } from "./
|
|
50
|
-
export {
|
|
51
|
-
export { yieldAncestorUrls } from "./
|
|
46
|
+
} from "./shared/windows_file_path_utils.js";
|
|
47
|
+
export { isFileSystemPath } from "./shared/is_filesystem_path.js";
|
|
48
|
+
export { resolveUrl } from "./shared/resolve_url.js";
|
|
49
|
+
export { resolveDirectoryUrl } from "./shared/resolve_directory_url.js";
|
|
50
|
+
export { urlIsOrIsInsideOf } from "./shared/url_is_or_is_inside_of.js";
|
|
51
|
+
export { yieldAncestorUrls } from "./shared/yield_ancestor_urls.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { isFileSystemPath } from "../shared/is_filesystem_path.js";
|
|
1
2
|
import { fileSystemPathToUrl } from "./filesystem_path_to_url.js";
|
|
2
|
-
import { isFileSystemPath } from "./is_filesystem_path.js";
|
|
3
3
|
|
|
4
4
|
export const getCallerPosition = () => {
|
|
5
5
|
const { prepareStackTrace } = Error;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ensurePathnameTrailingSlash } from "../composition/set_url_part.js";
|
|
2
1
|
import { resolveUrl } from "./resolve_url.js";
|
|
2
|
+
import { ensurePathnameTrailingSlash } from "./set_url_part.js";
|
|
3
3
|
|
|
4
4
|
export const resolveDirectoryUrl = (specifier, baseUrl) => {
|
|
5
5
|
const url = resolveUrl(specifier, baseUrl);
|
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import { filenameToBasename } from "./url_to_basename.js";
|
|
2
2
|
import { urlToExtension } from "./url_to_extension.js";
|
|
3
3
|
import { pathnameToFilename } from "./url_to_filename.js";
|
|
4
|
-
import { urlToOrigin } from "./url_to_origin.js";
|
|
5
|
-
import { urlToResource } from "./url_to_resource.js";
|
|
6
4
|
|
|
7
|
-
export const setUrlExtension = (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
5
|
+
export const setUrlExtension = (
|
|
6
|
+
url,
|
|
7
|
+
extension,
|
|
8
|
+
{ trailingSlash = "preserve" } = {},
|
|
9
|
+
) => {
|
|
10
|
+
return transformUrlPathname(url, (pathname) => {
|
|
11
|
+
const currentExtension = urlToExtension(url);
|
|
12
|
+
if (typeof extension === "function") {
|
|
13
|
+
extension = extension(currentExtension);
|
|
14
|
+
}
|
|
15
|
+
const pathnameWithoutExtension = currentExtension
|
|
16
|
+
? pathname.slice(0, -currentExtension.length)
|
|
17
|
+
: pathname;
|
|
18
|
+
|
|
19
|
+
if (pathnameWithoutExtension.endsWith("/")) {
|
|
20
|
+
let pathnameWithExtension;
|
|
21
|
+
pathnameWithExtension = pathnameWithoutExtension.slice(0, -1);
|
|
22
|
+
pathnameWithExtension += extension;
|
|
23
|
+
if (trailingSlash === "preserve") {
|
|
24
|
+
pathnameWithExtension += "/";
|
|
25
|
+
}
|
|
26
|
+
return pathnameWithExtension;
|
|
27
|
+
}
|
|
28
|
+
let pathnameWithExtension = pathnameWithoutExtension;
|
|
29
|
+
pathnameWithExtension += extension;
|
|
30
|
+
return pathnameWithExtension;
|
|
31
|
+
});
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
export const setUrlFilename = (url, filename) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const urlIsOrIsInsideOf = (url, otherUrl) => {
|
|
2
2
|
const urlObject = new URL(url);
|
|
3
3
|
const otherUrlObject = new URL(otherUrl);
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ export const urlIsInsideOf = (url, otherUrl) => {
|
|
|
9
9
|
const urlPathname = urlObject.pathname;
|
|
10
10
|
const otherUrlPathname = otherUrlObject.pathname;
|
|
11
11
|
if (urlPathname === otherUrlPathname) {
|
|
12
|
-
return
|
|
12
|
+
return true;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const isInside = urlPathname.startsWith(otherUrlPathname);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|