Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: unjs/ufo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.5.2
Choose a base ref
...
head repository: unjs/ufo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.5.3
Choose a head ref
  • 3 commits
  • 5 files changed
  • 2 contributors

Commits on Mar 18, 2024

  1. chore(release): v1.5.2

    pi0 committed Mar 18, 2024
    Copy the full SHA
    c84812a View commit details

Commits on Mar 20, 2024

  1. chore(deps): update devdependency @types/node to ^20.11.30 (#227)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Mar 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    8ba494b View commit details
  2. fix(joinRelativeURL): avoid lookbehind regex for browser compatibility (

    pi0 authored Mar 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9713f2f View commit details
Showing with 40 additions and 19 deletions.
  1. +12 −0 CHANGELOG.md
  2. +2 −2 package.json
  3. +14 −14 pnpm-lock.yaml
  4. +8 −3 src/utils.ts
  5. +4 −0 test/join.test.ts
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,18 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## v1.5.2

[compare changes](https://github.com/unjs/ufo/compare/v1.5.1...v1.5.2)

### 🩹 Fixes

- Use lookbehind regex only inside `joinRelativeURL` ([#226](https://github.com/unjs/ufo/pull/226))

### ❤️ Contributors

- Pooya Parsa ([@pi0](http://github.com/pi0))

## v1.5.1

[compare changes](https://github.com/unjs/ufo/compare/v1.5.0...v1.5.1)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ufo",
"version": "1.5.1",
"version": "1.5.2",
"description": "URL utils for humans",
"repository": "unjs/ufo",
"license": "MIT",
@@ -30,7 +30,7 @@
"test": "pnpm lint && vitest run --typecheck"
},
"devDependencies": {
"@types/node": "^20.11.28",
"@types/node": "^20.11.30",
"@vitest/coverage-v8": "^1.4.0",
"automd": "^0.3.6",
"changelogen": "^0.5.5",
28 changes: 14 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -345,8 +345,8 @@ export function joinURL(base: string, ...input: string[]): string {
* @group utils
*/
export function joinRelativeURL(..._input: string[]): string {
// Inlined regex to increase browser compatibiltiy for lookbehind (#224)
const JOIN_SEGMENT_SPLIT_RE = /(?<!\/)\/(?!\/)/;
// Inlined regex to increase browser compatibiltiy
const JOIN_SEGMENT_SPLIT_RE = /\/(?!\/)/;

const input = _input.filter(Boolean);

@@ -358,7 +358,7 @@ export function joinRelativeURL(..._input: string[]): string {
if (!i || i === "/") {
continue;
}
for (const s of i.split(JOIN_SEGMENT_SPLIT_RE)) {
for (const [sindex, s] of i.split(JOIN_SEGMENT_SPLIT_RE).entries()) {
if (!s || s === ".") {
continue;
}
@@ -370,6 +370,11 @@ export function joinRelativeURL(..._input: string[]): string {
segmentsDepth--;
continue;
}
// eslint-disable-next-line unicorn/prefer-at
if (sindex === 1 && segments[segments.length - 1]?.endsWith(":/")) {
segments[segments.length - 1] += "/" + s;
continue;
}
segments.push(s);
segmentsDepth++;
}
4 changes: 4 additions & 0 deletions test/join.test.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,10 @@ const joinURLTests = [
input: ["https://google.com/", "./foo", "/bar"],
out: "https://google.com/foo/bar",
},
{
input: ["//google.com/", "./foo", "/bar"],
out: "//google.com/foo/bar",
},
] as const;

describe("joinURL", () => {