@jsenv/urls 2.3.0 → 2.3.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/urls",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,6 +28,6 @@
28
28
  "test": "node --conditions=development ./scripts/test.mjs"
29
29
  },
30
30
  "dependencies": {
31
- "@jsenv/humanize": "1.2.4"
31
+ "@jsenv/humanize": "1.2.5"
32
32
  }
33
33
  }
@@ -1,5 +1,5 @@
1
- import { isFileSystemPath } from "./is_filesystem_path.js";
2
1
  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;
package/src/main.js CHANGED
@@ -1,3 +1,5 @@
1
+ // tslint:disable:ordered-imports
2
+
1
3
  export { DATA_URL } from "./data_url.js";
2
4
  export { stringifyUrlSite } from "./url_trace.js";
3
5
  export {
@@ -1,5 +1,5 @@
1
- import { ensurePathnameTrailingSlash } from "./url_utils.js";
2
1
  import { resolveUrl } from "./resolve_url.js";
2
+ import { ensurePathnameTrailingSlash } from "./url_utils.js";
3
3
 
4
4
  export const resolveDirectoryUrl = (specifier, baseUrl) => {
5
5
  const url = resolveUrl(specifier, baseUrl);
package/src/url_utils.js CHANGED
@@ -1,5 +1,5 @@
1
- import { urlToOrigin } from "./url_to_origin.js";
2
1
  import { urlToExtension } from "./url_to_extension.js";
2
+ import { urlToOrigin } from "./url_to_origin.js";
3
3
  import { urlToResource } from "./url_to_resource.js";
4
4
 
5
5
  export const asUrlWithoutSearch = (url) => {
@@ -144,7 +144,15 @@ export const setUrlExtension = (url, extension) => {
144
144
  const pathnameWithoutExtension = currentExtension
145
145
  ? pathname.slice(0, -currentExtension.length)
146
146
  : pathname;
147
- const newPathname = `${pathnameWithoutExtension}${extension}`;
147
+ let newPathname;
148
+ if (pathnameWithoutExtension.endsWith("/")) {
149
+ newPathname = pathnameWithoutExtension.slice(0, -1);
150
+ newPathname += extension;
151
+ newPathname += "/";
152
+ } else {
153
+ newPathname = pathnameWithoutExtension;
154
+ newPathname += extension;
155
+ }
148
156
  return `${origin}${newPathname}${search ? `?${search}` : ""}`;
149
157
  };
150
158