Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting infinite redirect? #69

Open
CWSites opened this issue Jul 2, 2024 · 1 comment
Open

Getting infinite redirect? #69

CWSites opened this issue Jul 2, 2024 · 1 comment

Comments

@CWSites
Copy link

CWSites commented Jul 2, 2024

I'm running into some weird behavior, if I click on a link which goes to /privacy-policy then the SPA redirects fine. However if I try to go directly to /privacy-policy I get stuck in a redirect loop.

https://mydomain.com/privacy-policy/?p=/&q=p=/~and~q=p=/~and~q=p=/~and~q=p=/~and~q=p=/~and~q=p=/~and~q=p=/

I'm using the code from the repo... what am I doing wrong?

var pathSegmentsToKeep = 1;

var l = window.location;
l.replace(
  l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
  l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
  l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
  (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
  l.hash
);
@GreeningSiren
Copy link

On a custom domain, pathSegmentsToKeep should be 0 instead of 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants