mirror of https://github.com/status-im/codimd.git
fix: handle when request url has no valid referer
Signed-off-by: Max Wu <jackymaxj@gmail.com>
This commit is contained in:
parent
37b656df93
commit
5e709653ab
|
@ -8,8 +8,15 @@ exports.setReturnToFromReferer = function setReturnToFromReferer (req) {
|
||||||
if (!req.session) req.session = {}
|
if (!req.session) req.session = {}
|
||||||
|
|
||||||
var referer = req.get('referer')
|
var referer = req.get('referer')
|
||||||
|
var nextURL
|
||||||
|
if (referer) {
|
||||||
|
try {
|
||||||
var refererSearchParams = new URLSearchParams(new URL(referer).search)
|
var refererSearchParams = new URLSearchParams(new URL(referer).search)
|
||||||
var nextURL = refererSearchParams.get('next')
|
nextURL = refererSearchParams.get('next')
|
||||||
|
} catch (err) {
|
||||||
|
logger.warn(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (nextURL) {
|
if (nextURL) {
|
||||||
var isRelativeNextURL = nextURL.indexOf('://') === -1 && !nextURL.startsWith('//')
|
var isRelativeNextURL = nextURL.indexOf('://') === -1 && !nextURL.startsWith('//')
|
||||||
|
|
Loading…
Reference in New Issue