-
-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
query parameters removed when using useLocalePath #2020
Comments
That's odd, I expanded on your reproduction to demonstrate which approach does and doesn't work here https://stackblitz.com/edit/github-mbabk8?file=pages/index.vue It looks like there's some inconsistency with the links generated by |
@BobbieGoede Could be related to this change in |
I encountered the same problem. Using |
@Red-Asuka same problem. |
@kazupon Hello, I noticed that the 8.0.0-rc.1 release notes indicate that this issue has been fixed. I tried to upgrade to this version, but the test results show that the above issue still exists.
|
+1 Having the same issue with |
Did some investigation, found the potential reason, a possible solution and created new issue in the intlify routing repo |
I have encapsulated the localePath function and temporarily solved this issue. utils/i18nLocalePath.ts import type { RawLocation } from '@intlify/vue-router-bridge'
import type { RouteLocation } from '.nuxt/vue-router'
function getUrlQueryStr(originalUrl: string) {
const { $config: { public: { baseUrl } } } = useNuxtApp()
const urlObj = new URL(originalUrl, baseUrl)
const queryStr = urlObj.search + urlObj.hash
return queryStr
}
export function i18nLocalePath(path: RawLocation | RouteLocation, lang?: Lang) {
const { $i18n: { locale } } = useNuxtApp()
const localePath = useLocalePath()
const loc = lang ?? locale.value
let queryStr = ''
if (typeof path === 'string' && (path.includes('?') || path.includes('#')))
queryStr = getUrlQueryStr(path)
const url = localePath(path, loc)
return `${url}${queryStr}`
} |
Wow thanks, that was fast! |
@kazupon When the path is the const localePath = useLocalePath()
console.log(localePath('/'))
console.log(localePath('/#hash'))
console.log(localePath('/?test=1#hash'))
// result:
// /en
// /en/
// /en?test=1%23hash |
@Red-Asuka |
Environment
Reproduction
https://github.com/AwesomeAnders/my-app
In above scenario - if you navigate from the index page to the about page, the query paramteres will disappear
Describe the bug
query paramteres will disappear when using useLocalePath
Additional context
This has been mentioned earlier:
#1967
Logs
No response
The text was updated successfully, but these errors were encountered: