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: v0.8.4
Choose a base ref
...
head repository: unjs/ufo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.8.5
Choose a head ref
  • 4 commits
  • 5 files changed
  • 3 contributors

Commits on Jun 10, 2022

  1. chore(deps): update pnpm to v7 (#61)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Jun 10, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    isaacs isaacs
    Copy the full SHA
    cbdda7a View commit details

Commits on Jul 7, 2022

  1. fix(withoutBase): preserve leading slash

    resolves #64
    pi0 committed Jul 7, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    fc72dd0 View commit details
  2. chore(deps): update all non-major dependencies (#63)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 7, 2022

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    3e08f97 View commit details
  3. chore(release): 0.8.5

    pi0 committed Jul 7, 2022

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    ce0fd83 View commit details
Showing with 397 additions and 315 deletions.
  1. +7 −0 CHANGELOG.md
  2. +3 −3 package.json
  3. +380 −308 pnpm-lock.yaml
  4. +4 −3 src/utils.ts
  5. +3 −1 test/base.test.ts
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,13 @@

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.

### [0.8.5](https://github.com/unjs/ufo/compare/v0.8.4...v0.8.5) (2022-07-07)


### Bug Fixes

* **withoutBase:** preserve leading slash ([fc72dd0](https://github.com/unjs/ufo/commit/fc72dd0b7e503c07e4788ebb7af6fb790c714035)), closes [#64](https://github.com/unjs/ufo/issues/64)

### [0.8.4](https://github.com/unjs/ufo/compare/v0.8.3...v0.8.4) (2022-05-06)


6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ufo",
"version": "0.8.4",
"version": "0.8.5",
"description": "URL utils for humans",
"repository": "unjs/ufo",
"license": "MIT",
@@ -31,12 +31,12 @@
"@nuxtjs/eslint-config-typescript": "latest",
"@types/flat": "latest",
"@types/node": "latest",
"c8": "^7.11.2",
"c8": "^7.11.3",
"eslint": "latest",
"standard-version": "latest",
"typescript": "latest",
"unbuild": "latest",
"vitest": "latest"
},
"packageManager": "pnpm@6.32.11"
"packageManager": "pnpm@7.5.0"
}
688 changes: 380 additions & 308 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -77,10 +77,11 @@ export function withoutBase (input: string, base: string) {
return input
}
const _base = withoutTrailingSlash(base)
if (input.startsWith(_base)) {
return input.substr(_base.length) || '/'
if (!input.startsWith(_base)) {
return input
}
return input
const trimmed = input.substring(_base.length)
return trimmed[0] === '/' ? trimmed : ('/' + trimmed)
}

export function withQuery (input: string, query: QueryObject): string {
4 changes: 3 additions & 1 deletion test/base.test.ts
Original file line number Diff line number Diff line change
@@ -31,7 +31,9 @@ describe('withoutBase', () => {
{ base: '/base', input: '/base/a', out: '/a' },
{ base: '/base/', input: '/base/a', out: '/a' },
{ base: '/base/a/', input: '/base/a', out: '/' },
{ base: '/', input: '/test/', out: '/test/' }
{ base: '/', input: '/test/', out: '/test/' },
{ base: '/', input: '/?test', out: '/?test' },
{ base: '/api', input: '/api?test', out: '/?test' }
]

for (const t of tests) {