Skip to content

Commit

Permalink
fix: adjustments to URL redirect to support urls without index.html (…
Browse files Browse the repository at this point in the history
…root) (#163)
  • Loading branch information
NateBaldwinDesign authored May 23, 2022
1 parent 41fb11c commit 48885ba
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/ui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,18 @@ posthtml()
// Redirect for URL parameters
let url = new URL(window.location);
let params = new URLSearchParams(url.search.slice(1));
console.log(url.href)

if(params.has('colorKeys') || params.has('name')) {
let newURL = url.href.replace('index', 'theme')
let newURL;
// if URL includes "index", replace with "theme"
if(JSON.stringify(url.href).includes('index')) {
newURL = url.href.replace('index', 'theme')
}
// if URL is at root, such as leonardocolor.io/?params, redirect to "theme"
else {
newURL = url.href.replace('/?', '/theme?')
}

window.location.replace(newURL);
}

Expand Down

0 comments on commit 48885ba

Please sign in to comment.