Skip to content

feat: accept route locations in buildUrl - #3798

Merged
dschmidt merged 4 commits into
mainfrom
feat/build-url-route-location
Oct 20, 2026
Merged

dschmidt merged 4 commits into
mainfrom
feat/build-url-route-location

Conversation

@dschmidt

@dschmidt dschmidt commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

buildUrl(router, to) now accepts everything router.resolve accepts, not only a path string. String calls behave as before.

// before
buildUrl(router, router.resolve({ name: 'pastebin-view', params }).fullPath)
// after
buildUrl(router, { name: 'pastebin-view', params })

I ran into this in the pastebin app (opencloud-eu/web-extensions#628), which needs an absolute link to its own route. With a route location, the route name stays the single source of truth and the extra lookup goes away.

Also in this PR:

  • Query fix: in history mode the href was assigned to URL.pathname, so a query came out as /app/view%3Fx=1.
  • Call sites: the picker modals, the editor links opened in a new tab and the pathchange event built URLs with window.location.origin by hand and now use buildUrl. With the default <base href="/"> nothing changes. In hash mode they dropped the current path, and the pathchange URLs missed the # and, under a sub path, the base path.
  • Test setup: production builds always have <base href="/">, unit tests had none, so vitest.init.ts now adds it.

Related Issue

How Has This Been Tested?

  • new buildUrl unit tests with a real router: named routes with params and query, hash and history mode, with and without base path; the query cases fail without the fix
  • full unit test suite, eslint, prettier, vue-tsc

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

buildUrl now takes everything router.resolve takes, so callers can pass a named route instead of a path. In history mode a query in the resolved route is kept instead of being encoded into the path.
The picker modals, the editor links opened in a new tab and the pathchange event built absolute urls from window.location.origin. That drops the base path in hash mode, and for the pathchange event also in history mode, since fullPath does not include the base.
@dschmidt
dschmidt marked this pull request as ready for review October 14, 2026 13:48
@dschmidt
dschmidt merged commit 5f1e994 into main Oct 20, 2026
27 checks passed
@dschmidt
dschmidt deleted the feat/build-url-route-location branch October 20, 2026 08:55
@openclouders openclouders mentioned this pull request Oct 20, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants