From 617458873f76e6b65ff62b89a3ccfc55ca9c05d6 Mon Sep 17 00:00:00 2001 From: Rijul Gupta Date: Thu, 28 Feb 2019 10:37:49 +1100 Subject: [PATCH 1/2] Update link mixin to resolve url from router if possible --- src/mixins/link.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/mixins/link.js b/src/mixins/link.js index e2ff4d86..b0fbd37b 100644 --- a/src/mixins/link.js +++ b/src/mixins/link.js @@ -15,12 +15,30 @@ export default { return oneOf(value, ['_blank', '_self', '_parent', '_top']); }, default: '_self' - } + }, + append: { + type: Boolean, + required: false, + default: false, + }, }, computed: { linkUrl () { const type = typeof this.to; - return type === 'string' ? this.to : null; + if (type !== 'string') { + return null; + } + if (this.to.includes('//')) { + /* Absolute URL, we do not need to route this */ + return this.to; + } + const router = this.$router; + if (router) { + const current = this.$route; + const route = router.resolve(this.to, current, this.append); + return route ? route.href : null; + } + return this.to; } }, methods: { From ad93e7a6fb6549165cf848af83dc9aa1f492fdf5 Mon Sep 17 00:00:00 2001 From: Rijul Gupta Date: Thu, 28 Feb 2019 11:07:55 +1100 Subject: [PATCH 2/2] Updated null to return the original URL as we already check for null before --- src/mixins/link.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixins/link.js b/src/mixins/link.js index b0fbd37b..984e03c9 100644 --- a/src/mixins/link.js +++ b/src/mixins/link.js @@ -36,7 +36,7 @@ export default { if (router) { const current = this.$route; const route = router.resolve(this.to, current, this.append); - return route ? route.href : null; + return route ? route.href : this.to; } return this.to; }