mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
refactor: use ufo.hasProtocol
to detect external link (#3686)
This commit is contained in:
parent
f38cacec0f
commit
04026a3861
@ -55,7 +55,7 @@
|
|||||||
"postcss-url": "^10.1.3",
|
"postcss-url": "^10.1.3",
|
||||||
"scule": "^0.2.1",
|
"scule": "^0.2.1",
|
||||||
"semver": "^7.3.5",
|
"semver": "^7.3.5",
|
||||||
"ufo": "^0.7.11",
|
"ufo": "^0.8.0",
|
||||||
"unplugin": "^0.5.2",
|
"unplugin": "^0.5.2",
|
||||||
"unplugin-vue2-script-setup": "^0.10.0",
|
"unplugin-vue2-script-setup": "^0.10.0",
|
||||||
"untyped": "^0.4.3",
|
"untyped": "^0.4.3",
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
"serve-static": "^1.14.2",
|
"serve-static": "^1.14.2",
|
||||||
"std-env": "^3.0.1",
|
"std-env": "^3.0.1",
|
||||||
"table": "^6.8.0",
|
"table": "^6.8.0",
|
||||||
"ufo": "^0.7.11",
|
"ufo": "^0.8.0",
|
||||||
"unenv": "^0.4.3",
|
"unenv": "^0.4.3",
|
||||||
"unstorage": "^0.3.3",
|
"unstorage": "^0.3.3",
|
||||||
"vue-bundle-renderer": "^0.3.5",
|
"vue-bundle-renderer": "^0.3.5",
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
"ohmyfetch": "^0.4.15",
|
"ohmyfetch": "^0.4.15",
|
||||||
"pathe": "^0.2.0",
|
"pathe": "^0.2.0",
|
||||||
"scule": "^0.2.1",
|
"scule": "^0.2.1",
|
||||||
"ufo": "^0.7.11",
|
"ufo": "^0.8.0",
|
||||||
"unimport": "^0.1.0",
|
"unimport": "^0.1.0",
|
||||||
"unplugin": "^0.5.2",
|
"unplugin": "^0.5.2",
|
||||||
"untyped": "^0.4.3",
|
"untyped": "^0.4.3",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { defineComponent, h, resolveComponent, PropType, computed, DefineComponent } from 'vue'
|
import { defineComponent, h, resolveComponent, PropType, computed, DefineComponent } from 'vue'
|
||||||
import { RouteLocationRaw, Router } from 'vue-router'
|
import { RouteLocationRaw, Router } from 'vue-router'
|
||||||
|
import { hasProtocol } from 'ufo'
|
||||||
|
|
||||||
import { useRouter } from '#app'
|
import { useRouter } from '#app'
|
||||||
|
|
||||||
@ -140,10 +141,8 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Directly check if `to` is an external URL with Regex
|
// Directly check if `to` is an external URL by checking protocol
|
||||||
// Regex101 expression: {@link https://regex101.com/r/1y7iod/1}
|
return hasProtocol(to.value, true)
|
||||||
// TODO: Use `ufo.hasProtocol` when issue fixed https://github.com/unjs/ufo/issues/45
|
|
||||||
return !/^\/(?!\/)/.test(to.value)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
"postcss-import-resolver": "^2.0.0",
|
"postcss-import-resolver": "^2.0.0",
|
||||||
"scule": "^0.2.1",
|
"scule": "^0.2.1",
|
||||||
"std-env": "^3.0.1",
|
"std-env": "^3.0.1",
|
||||||
"ufo": "^0.7.11",
|
"ufo": "^0.8.0",
|
||||||
"unimport": "^0.1.0"
|
"unimport": "^0.1.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
"postcss-url": "^10.1.3",
|
"postcss-url": "^10.1.3",
|
||||||
"rollup": "^2.70.1",
|
"rollup": "^2.70.1",
|
||||||
"rollup-plugin-visualizer": "^5.6.0",
|
"rollup-plugin-visualizer": "^5.6.0",
|
||||||
"ufo": "^0.7.11",
|
"ufo": "^0.8.0",
|
||||||
"unplugin": "^0.5.2",
|
"unplugin": "^0.5.2",
|
||||||
"vite": "^2.8.6",
|
"vite": "^2.8.6",
|
||||||
"vite-node": "^0.6.1"
|
"vite-node": "^0.6.1"
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
"postcss-url": "^10.1.3",
|
"postcss-url": "^10.1.3",
|
||||||
"style-resources-loader": "^1.5.0",
|
"style-resources-loader": "^1.5.0",
|
||||||
"time-fix-plugin": "^2.0.7",
|
"time-fix-plugin": "^2.0.7",
|
||||||
"ufo": "^0.7.11",
|
"ufo": "^0.8.0",
|
||||||
"unplugin": "^0.5.2",
|
"unplugin": "^0.5.2",
|
||||||
"url-loader": "^4.1.1",
|
"url-loader": "^4.1.1",
|
||||||
"vue-loader": "^17.0.0",
|
"vue-loader": "^17.0.0",
|
||||||
|
19
yarn.lock
19
yarn.lock
@ -2745,7 +2745,7 @@ __metadata:
|
|||||||
postcss-url: ^10.1.3
|
postcss-url: ^10.1.3
|
||||||
scule: ^0.2.1
|
scule: ^0.2.1
|
||||||
semver: ^7.3.5
|
semver: ^7.3.5
|
||||||
ufo: ^0.7.11
|
ufo: ^0.8.0
|
||||||
unbuild: latest
|
unbuild: latest
|
||||||
unplugin: ^0.5.2
|
unplugin: ^0.5.2
|
||||||
unplugin-vue2-script-setup: ^0.10.0
|
unplugin-vue2-script-setup: ^0.10.0
|
||||||
@ -3153,7 +3153,7 @@ __metadata:
|
|||||||
serve-static: ^1.14.2
|
serve-static: ^1.14.2
|
||||||
std-env: ^3.0.1
|
std-env: ^3.0.1
|
||||||
table: ^6.8.0
|
table: ^6.8.0
|
||||||
ufo: ^0.7.11
|
ufo: ^0.8.0
|
||||||
unbuild: latest
|
unbuild: latest
|
||||||
unenv: ^0.4.3
|
unenv: ^0.4.3
|
||||||
unstorage: ^0.3.3
|
unstorage: ^0.3.3
|
||||||
@ -3206,7 +3206,7 @@ __metadata:
|
|||||||
postcss-import-resolver: ^2.0.0
|
postcss-import-resolver: ^2.0.0
|
||||||
scule: ^0.2.1
|
scule: ^0.2.1
|
||||||
std-env: ^3.0.1
|
std-env: ^3.0.1
|
||||||
ufo: ^0.7.11
|
ufo: ^0.8.0
|
||||||
unbuild: latest
|
unbuild: latest
|
||||||
unimport: ^0.1.0
|
unimport: ^0.1.0
|
||||||
languageName: unknown
|
languageName: unknown
|
||||||
@ -3449,7 +3449,7 @@ __metadata:
|
|||||||
postcss-url: ^10.1.3
|
postcss-url: ^10.1.3
|
||||||
rollup: ^2.70.1
|
rollup: ^2.70.1
|
||||||
rollup-plugin-visualizer: ^5.6.0
|
rollup-plugin-visualizer: ^5.6.0
|
||||||
ufo: ^0.7.11
|
ufo: ^0.8.0
|
||||||
unbuild: latest
|
unbuild: latest
|
||||||
unplugin: ^0.5.2
|
unplugin: ^0.5.2
|
||||||
vite: ^2.8.6
|
vite: ^2.8.6
|
||||||
@ -3569,7 +3569,7 @@ __metadata:
|
|||||||
postcss-url: ^10.1.3
|
postcss-url: ^10.1.3
|
||||||
style-resources-loader: ^1.5.0
|
style-resources-loader: ^1.5.0
|
||||||
time-fix-plugin: ^2.0.7
|
time-fix-plugin: ^2.0.7
|
||||||
ufo: ^0.7.11
|
ufo: ^0.8.0
|
||||||
unbuild: latest
|
unbuild: latest
|
||||||
unplugin: ^0.5.2
|
unplugin: ^0.5.2
|
||||||
url-loader: ^4.1.1
|
url-loader: ^4.1.1
|
||||||
@ -15801,7 +15801,7 @@ __metadata:
|
|||||||
ohmyfetch: ^0.4.15
|
ohmyfetch: ^0.4.15
|
||||||
pathe: ^0.2.0
|
pathe: ^0.2.0
|
||||||
scule: ^0.2.1
|
scule: ^0.2.1
|
||||||
ufo: ^0.7.11
|
ufo: ^0.8.0
|
||||||
unbuild: latest
|
unbuild: latest
|
||||||
unimport: ^0.1.0
|
unimport: ^0.1.0
|
||||||
unplugin: ^0.5.2
|
unplugin: ^0.5.2
|
||||||
@ -21314,6 +21314,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"ufo@npm:^0.8.0":
|
||||||
|
version: 0.8.0
|
||||||
|
resolution: "ufo@npm:0.8.0"
|
||||||
|
checksum: cab38504a4caf316a9b24d187d24400c403599d563c260fbdad5e61371ed0be756edb8d1e0b322f37a4c8893e7496e47ea193f1cb039c343e6f6924a95ccadfe
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"uglify-js@npm:^3.1.4, uglify-js@npm:^3.5.1":
|
"uglify-js@npm:^3.1.4, uglify-js@npm:^3.5.1":
|
||||||
version: 3.15.2
|
version: 3.15.2
|
||||||
resolution: "uglify-js@npm:3.15.2"
|
resolution: "uglify-js@npm:3.15.2"
|
||||||
|
Loading…
Reference in New Issue
Block a user