From a7c88dc57a5fb019835dac66019c440b70723837 Mon Sep 17 00:00:00 2001 From: He Weiwei Date: Wed, 18 Apr 2018 14:42:33 +0800 Subject: [PATCH 1/2] fix fullPathRedirect --- lib/core/auth.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/auth.js b/lib/core/auth.js index 92a2ad3e9..38490aa20 100644 --- a/lib/core/auth.js +++ b/lib/core/auth.js @@ -304,7 +304,7 @@ export default class Auth { return } - const from = this.options.fullPathRedirect ? this.ctx.route.path : this.ctx.route.fullPath + const from = this.options.fullPathRedirect ? this.ctx.route.fullPath : this.ctx.route.path let to = this.options.redirect[name] if (!to) { @@ -313,7 +313,7 @@ export default class Auth { // Apply rewrites if (this.options.rewriteRedirects) { - if (name === 'login' && isRelativeURL(from) && !isSameURL(to, from)) { + if (name === 'login' && isRelativeURL(from.split('?')[0]) && !isSameURL(to, from)) { this.$storage.setUniversal('redirect', from) } From 167d0eaa8a2d720272b5c419af1400408a134744 Mon Sep 17 00:00:00 2001 From: He Weiwei Date: Thu, 19 Apr 2018 00:26:38 +0800 Subject: [PATCH 2/2] make isRelativeURL match path with query and fragment --- lib/core/auth.js | 2 +- lib/core/utilities.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/auth.js b/lib/core/auth.js index 38490aa20..f03222a78 100644 --- a/lib/core/auth.js +++ b/lib/core/auth.js @@ -313,7 +313,7 @@ export default class Auth { // Apply rewrites if (this.options.rewriteRedirects) { - if (name === 'login' && isRelativeURL(from.split('?')[0]) && !isSameURL(to, from)) { + if (name === 'login' && isRelativeURL(from) && !isSameURL(to, from)) { this.$storage.setUniversal('redirect', from) } diff --git a/lib/core/utilities.js b/lib/core/utilities.js index f24a1e400..7fd1343ab 100644 --- a/lib/core/utilities.js +++ b/lib/core/utilities.js @@ -4,7 +4,7 @@ export const isSet = o => !isUnset(o) export const isSameURL = (a, b) => a.split('?')[0] === b.split('?')[0] export const isRelativeURL = u => - u && u.length && /^\/[a-zA-Z0-9@\-%_~][/a-zA-Z0-9@\-%_~]{1,200}$/.test(u) + u && u.length && /^\/[a-zA-Z0-9@\-%_~][/a-zA-Z0-9@\-%_~]*[\?]?([^\#]*)#?([^\#]*)$/.test(u) export const parseQuery = queryString => { const query = {}