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

Traditional urls getting rewritten if period (.) is in the hash #316

Open
patrickliechty opened this issue Jul 8, 2013 · 9 comments
Open

Comments

@patrickliechty
Copy link

We are using history 1.7.1. We have cases where a period is part of the a hash parameter value. In onPopState in History.js it calls replaceState because it says it found a state. This causes a rewrite of the url from:

http://localhost:5000/search/record/results#count=20&query=%2Bgivenname%3Apatrick~%20%2Bsurname%3Ajones.~

to

http://localhost:5000/search/record/count=20&query=+givenname:patrick~%20+surname:jones.~

All because it is thinks it is a traditional url. Here is the function:

    History.isTraditionalAnchor = function(url_or_hash){
        // Check
        var isTraditional = !(/[\/\?\.]/.test(url_or_hash));
        // Return
        return isTraditional;
    };

Why isTraditionalAnchor looking for a period? I don't understand how a tradition anchor is determined by a / . or ?

At any rate, it appears to be a bug unless I am not understanding this. It is not fixed in 1.8.0 either.

@igor-alexandrov
Copy link
Contributor

I have similar problems in #315.

@patrickliechty
Copy link
Author

I created a pull request to fix this. #322

@pmaselkowski
Copy link

Any reason why dot is still used as separator?

According to http://tools.ietf.org/html/rfc3986 dot is valid character for fragment.

This causes rewrite of hash with dot into path, ie:

/admin/messages/#1jY4xnOMD_sort

Becomes

/admin/messages/1jY4xnOMD_sort

Had hard time figuring out why this happens.

@pmaselkowski
Copy link

There is a workaround for this issue. After including history.js, delay init, alter isTraditionalAnchor and init manually:

  History.options.delayInit = true;

  History.isTraditionalAnchor = function(url_or_hash) {
    var isTraditional;
    isTraditional = !(/[\/\?]/.test(url_or_hash));
    return isTraditional;
  };

  History.init();

@gareththackeray
Copy link

@pmaselkowski thanks - and your comment just in time for when I started looking at this issue!

@brunob2f
Copy link

brunob2f commented Apr 8, 2016

I had to alter the regexp this way : [?] otherwyse, the / is alos forbidden in the hash part

@kiflay
Copy link

kiflay commented Mar 7, 2017

@pmaselkowski I did add your script and the value of the isTraditional is false but the url is not updated.

url was

loungewear/icat/unisex-loungewear# size = XS

After changing size to size = X/S it becomes

loungewear/icat/size=XL/2X

@pmaselkowski
Copy link

@kiflay see brunob2f comment, maybe You need to tweak with regexp.

@kiflay
Copy link

kiflay commented Mar 9, 2017

Thanks @pmaselkowski

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

No branches or pull requests

6 participants