@jsenv/urls 1.2.1 → 1.2.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": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -7,9 +7,10 @@ export const getCommonPathname = (pathname, otherPathname) => {
7
7
  let i = 0
8
8
  const length = pathname.length
9
9
  const otherLength = otherPathname.length
10
- while (i < pathname.length) {
10
+ while (i < length) {
11
11
  const char = pathname.charAt(i)
12
12
  const otherChar = otherPathname.charAt(i)
13
+ i++
13
14
  if (char === otherChar) {
14
15
  if (char === "/") {
15
16
  commonPart += "/"
@@ -19,9 +20,12 @@ export const getCommonPathname = (pathname, otherPathname) => {
19
20
  commonPart += char
20
21
  }
21
22
  } else {
23
+ if (char === "/" && i - 1 === otherLength) {
24
+ commonPart += "/"
25
+ commonPathname += commonPart
26
+ }
22
27
  return commonPathname
23
28
  }
24
- i++
25
29
  }
26
30
  if (length === otherLength) {
27
31
  commonPathname += commonPart