Skip to content

fix: preserve query params on public link redirect#2199

Merged
JammingBen merged 2 commits intomainfrom
fix/preserve-query-params-on-public-link-redirect
Mar 23, 2026
Merged

fix: preserve query params on public link redirect#2199
JammingBen merged 2 commits intomainfrom
fix/preserve-query-params-on-public-link-redirect

Conversation

@dschmidt
Copy link
Contributor

@dschmidt dschmidt commented Mar 22, 2026

Summary

  • Vue Router's resolve() silently drops query params when they are embedded in the path string passed to router.push(). In resolvePublicLink, the redirectUrl is pushed as { path: url } where the URL contains query params (e.g. ?scrollTo=foo.txt), causing them to be lost after the redirect.
  • Added a parsePathQuery() helper in the router helpers that splits a URL string into separate path and query fields before pushing, so Vue Router receives query params explicitly.
  • An alternative approach of patching patchCleanPath to recover dropped query params was considered, but deemed too intrusive for now since it would affect all routes with patchCleanPath enabled.

Required to make scrollTo work in opencloud-eu/web-extensions#268 :)

Test plan

  • Open a public link URL with a custom query param (e.g. ?scrollTo=foo.txt)
  • Verify the query param is preserved after the public link resolution redirect
  • Verify existing public link resolution still works without query params

… link resolution

Vue Router's resolve() silently drops query params when they are embedded
in the path string passed to router.push(). This caused any custom query
params (e.g. scrollTo) in the redirectUrl to be lost during public link
resolution.

The fix splits the URL into separate path and query parts before pushing,
so Vue Router receives the query params explicitly.

An alternative approach of patching patchCleanPath to recover dropped
query params was considered, but deemed too intrusive for now since it
would affect all routes with patchCleanPath enabled.
replaceInvalidFileRoute was creating fresh route options via
createFileRouteOptions, dropping all existing query params like
scrollTo and contextRouteName. Merge the current route's query
into the replacement so extension apps can pass custom query
params that survive the route correction.
dschmidt added a commit to dschmidt/opencloud-web-extensions that referenced this pull request Mar 22, 2026
Replace window.location.search workaround with proper useRouteQuery
now that web-pkg's replaceInvalidFileRoute preserves query params
(opencloud-eu/web#2199). The scrollTo e2e test is skipped until that
fix is released.
dschmidt added a commit to dschmidt/opencloud-web-extensions that referenced this pull request Mar 22, 2026
…here

- Include folder fileId in anchor URLs so AppWrapper's
  replaceInvalidFileRoute preserves scrollTo query param
- Show anchor links on public link views too (fall back to current URL)
- Add e2e test that opens a public link with scrollTo and verifies
  the target file is visible (skipped until opencloud-eu/web#2199)
@JammingBen JammingBen merged commit f1cd7d5 into main Mar 23, 2026
28 checks passed
@JammingBen JammingBen deleted the fix/preserve-query-params-on-public-link-redirect branch March 23, 2026 10:20
@openclouders openclouders mentioned this pull request Mar 23, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants