rafgraph / spa-github-pages

Host single page apps with GitHub Pages
https://spa-github-pages.rafgraph.dev
MIT License
3.83k stars 565 forks source link

less hacky with `encodeURIComponent` and `decodeURIComponent` instead? #31

Closed choonkeat closed 3 years ago

choonkeat commented 5 years ago
- s.replace(/&/g, '~and~')
+ encodeURIComponent(s)

and

- s.replace(/~and~/g, '&')
+ decodeURIComponent(s)
rafgraph commented 3 years ago

Thanks for the suggestion. The reason I don't use this is for readability because the encoded url is what gets indexed by search engines and shows up in search results. For example, /one/two?a=b&c=d would get turned into /?%2Fone%2Ftwo&a%3Db%26c%3Dd using encodeURIComponent, compared to /?/one/two&a=b~and~c=d.