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

PathParse Help #471

Closed
j0nr opened this issue Oct 31, 2013 · 2 comments
Closed

PathParse Help #471

j0nr opened this issue Oct 31, 2013 · 2 comments

Comments

@j0nr
Copy link

j0nr commented Oct 31, 2013

Sorry if this is the wrong place to ask for help, I am not reporting a bug as such, but I cannot figure out how to get IS to do my URLs correctly. It works OOTB most of the time, but I have found one particular URL that it doesn't play nice with.

Here are some examples of the URLs I am encountering:

mysite.org/ - interpreted by rewrite rules in .htaccess as mysite.org/index.php (this works).

Within this page, there will be a link mysite.org/page2 which will get interpreted in .htaccess as mysite.org/index.php?p=2, which works.

Next I can add 'tags' into the URL like so:

mysite.org/word1/word2/

This is interpreted as mysite.org/index.php?t=words1/word2 (works)

Within this page, there will be a link mysite.org/word1/word2/page2 which will get interpreted in .htaccess as mysite.org/index.php?t=word1/word2&p=2, which works!

BUT, then I have the need to do this:

mysite.org/word1/word2/from2012-10-01/to2012-10-03/

which gets interpreted as mysite.org/index.php?t=word1/word2&from=2012-10-01&to=2012-10-03 which on its own works, but when the next page is tripped:

mysite.org/word1/word2/from2012-10-01/to2012-10-03/page2/

which should be turned into mysite.org/index.php?t=word1/word2&from=2012-10-01&to=2012-10-03&p=2 something goes wrong.

The problem is that IS is taking the next link:

mysite.org/word1/word2/from2012-10-01/to2012-10-03/page2/

and turning it into this:

mysite.org/word1/word2/from3012-10-01/to2012-10-03/page2/

and then the next will be this:

mysite.org/word1/word2/from4012-10-01/to2012-10-03/page2/

If you can see what it happening, it is incrementing the number after from ... it isn't recognising the (kinda obvious) page_n at the end and incrementing that. But this only happens when I have this from in my URL

HELP would be sooo appreciated as it is driving me mad :)

Thanks in advance.

Jon

@j0nr
Copy link
Author

j0nr commented Oct 31, 2013

Solved potentially with this:

...
pathParse: function(path,nextPage){
  var re = new RegExp('^(.*page)' + nextPage + '(\/.*|$)');    
  path = path.match(re).slice(1);                                       
  return path;
},
...

@desandro
Copy link
Member

desandro commented Jun 26, 2017

Thank you for reporting this issue.

Infinite Scroll v3 is out!. It's an all new re-write, so take a look at how to upgrade from v2.

Infinite Scroll v3 has better parsing of path. Additionally you can set path as a string with {{#}} for the page number.

path: '/word1/word2/from3012-10-01/to2012-10-03/page{{#}}/'

I recommend upgrading to v3. Please open a new issue if you run into trouble with Infinite Scroll v3. 🌈🐻

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

No branches or pull requests

2 participants