Skip to content

Commit

Permalink
build url without string concat
Browse files Browse the repository at this point in the history
  • Loading branch information
avatus committed Jul 1, 2022
1 parent e038ab9 commit 8bc3ae2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/web/app/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ const js = `
}).then(response => {
if (response.ok) {
try {
if (path.charAt(0) !== "/") {
throw "malformed url"
}
window.location.replace(url.origin + path);
var redirectUrl = new URL(path, url.origin)
window.location.replace(redirectUrl.toString());
} catch (error) {
// in case of malformed url, return to origin
window.location.replace(url.origin)
Expand Down

0 comments on commit 8bc3ae2

Please sign in to comment.