Skip to content

Commit

Permalink
fix(nuxt): avoid redirect with different encoding and trailing slash (n…
Browse files Browse the repository at this point in the history
…uxt#4857)

Co-authored-by: Pooya Parsa <pyapar@gmail.com>
  • Loading branch information
atinux and pi0 authored May 6, 2022
1 parent a58178c commit 9e5a3cd
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"pathe": "^0.3.0",
"perfect-debounce": "^0.1.3",
"scule": "^0.2.1",
"ufo": "^0.8.3",
"ufo": "^0.8.4",
"unctx": "^1.1.4",
"unenv": "^0.5.1",
"unimport": "^0.1.8",
Expand Down
4 changes: 2 additions & 2 deletions packages/nuxt/src/app/plugins/router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { reactive, h } from 'vue'
import { parseURL, parseQuery, withoutBase } from 'ufo'
import { parseURL, parseQuery, withoutBase, isEqual } from 'ufo'
import { createError } from 'h3'
import { defineNuxtPlugin } from '..'
import { callWithNuxt } from '../nuxt'
Expand Down Expand Up @@ -221,7 +221,7 @@ export default defineNuxtPlugin<{ route: Route, router: Router }>((nuxtApp) => {
})

await router.replace(initialURL)
if (route.fullPath !== initialURL) {
if (!isEqual(route.fullPath, initialURL)) {
await callWithNuxt(nuxtApp, navigateTo, [route.fullPath])
}
})
Expand Down
4 changes: 2 additions & 2 deletions packages/nuxt/src/pages/runtime/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
RouteLocation
} from 'vue-router'
import { createError } from 'h3'
import { withoutBase } from 'ufo'
import { withoutBase, isEqual } from 'ufo'
import NuxtPage from './page'
import { callWithNuxt, defineNuxtPlugin, useRuntimeConfig, throwError, clearError, navigateTo, useError } from '#app'
// @ts-ignore
Expand Down Expand Up @@ -177,7 +177,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {

if (process.server) {
const currentURL = to.fullPath || '/'
if (currentURL !== initialURL) {
if (!isEqual(currentURL, initialURL)) {
await callWithNuxt(nuxtApp, navigateTo, [currentURL])
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"postcss-import-resolver": "^2.0.0",
"scule": "^0.2.1",
"std-env": "^3.1.1",
"ufo": "^0.8.3",
"ufo": "^0.8.4",
"unimport": "^0.1.8"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"postcss-url": "^10.1.3",
"rollup": "^2.72.0",
"rollup-plugin-visualizer": "^5.6.0",
"ufo": "^0.8.3",
"ufo": "^0.8.4",
"unplugin": "^0.6.2",
"vite": "^2.9.8",
"vite-node": "^0.10.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"postcss-url": "^10.1.3",
"style-resources-loader": "^1.5.0",
"time-fix-plugin": "^2.0.7",
"ufo": "^0.8.3",
"ufo": "^0.8.4",
"unplugin": "^0.6.2",
"url-loader": "^4.1.1",
"vue-loader": "^17.0.0",
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ __metadata:
postcss-import-resolver: ^2.0.0
scule: ^0.2.1
std-env: ^3.1.1
ufo: ^0.8.3
ufo: ^0.8.4
unbuild: latest
unimport: ^0.1.8
languageName: unknown
Expand Down Expand Up @@ -1651,7 +1651,7 @@ __metadata:
postcss-url: ^10.1.3
rollup: ^2.72.0
rollup-plugin-visualizer: ^5.6.0
ufo: ^0.8.3
ufo: ^0.8.4
unbuild: latest
unplugin: ^0.6.2
vite: ^2.9.8
Expand Down Expand Up @@ -1699,7 +1699,7 @@ __metadata:
postcss-url: ^10.1.3
style-resources-loader: ^1.5.0
time-fix-plugin: ^2.0.7
ufo: ^0.8.3
ufo: ^0.8.4
unbuild: latest
unplugin: ^0.6.2
url-loader: ^4.1.1
Expand Down Expand Up @@ -10081,7 +10081,7 @@ __metadata:
pathe: ^0.3.0
perfect-debounce: ^0.1.3
scule: ^0.2.1
ufo: ^0.8.3
ufo: ^0.8.4
unbuild: latest
unctx: ^1.1.4
unenv: ^0.5.1
Expand Down Expand Up @@ -13231,10 +13231,10 @@ __metadata:
languageName: node
linkType: hard

"ufo@npm:^0.8.3":
version: 0.8.3
resolution: "ufo@npm:0.8.3"
checksum: 7ea20e9d0fbd92b3310de4b020919f0a0542db60a6787ccecf232285d55795ddc0ea482b04d6c07cac60367a294aee705d888999867a5c3c69e47ed8d0ae3009
"ufo@npm:^0.8.3, ufo@npm:^0.8.4":
version: 0.8.4
resolution: "ufo@npm:0.8.4"
checksum: a2ebef6f64b9cc4114fc65405837eeb83eb8975edd6d54c7f37abb6905da6fd1f63524e4a02c8b087e7b0b3db6e6f4f798a3d86a96500410ff590b405f807dc9
languageName: node
linkType: hard

Expand Down

0 comments on commit 9e5a3cd

Please sign in to comment.