Skip to content

Add redirect rule for biorxiv#4

Closed
zafarali wants to merge 1 commit intoimurray:masterfrom
zafarali:master
Closed

Add redirect rule for biorxiv#4
zafarali wants to merge 1 commit intoimurray:masterfrom
zafarali:master

Conversation

@zafarali
Copy link
Copy Markdown

@zafarali zafarali commented Mar 5, 2018

This PR adds support for biorxiv links that suffer from the same issue.

Tested on some links:

> rule = ["*://*biorxiv.org/*", /(.*)\/biorxiv\/(.*?)(.full.pdf)?$/, '$1/$2']
[ '*://*biorxiv.org/*',
  /(.*)\/biorxiv\/(.*?)(.full.pdf)?$/,
  '$1/$2' ]
> link = https://www.biorxiv.org/content/biorxiv/early/2017/09/18/113480.full.pdf
> link = 'https://www.biorxiv.org/content/biorxiv/early/2017/09/18/113480.full.pdf'
'https://www.biorxiv.org/content/biorxiv/early/2017/09/18/113480.full.pdf'
> link.replace(rule[1], rule[2])
'https://www.biorxiv.org/content/early/2017/09/18/113480'
> link = https://www.biorxiv.org/content/biorxiv/early/2018/03/03/275545.full.pdf
> link = 'https://www.biorxiv.org/content/biorxiv/early/2018/03/03/275545.full.pdf'
'https://www.biorxiv.org/content/biorxiv/early/2018/03/03/275545.full.pdf'
> link.replace(rule[1], rule[2])
'https://www.biorxiv.org/content/early/2018/03/03/275545'

If there are any sanity checks to run let me know!

@imurray
Copy link
Copy Markdown
Owner

imurray commented Mar 6, 2018

Thanks for the pull request! I created a separate commit because I wanted to tweak it a bit. The first element of the rule needed an extra '.' to work in Firefox. I also tweaked the regex so links like https://www.biorxiv.org/content/early/2018/03/06/276774.full.pdf.

@imurray imurray closed this Mar 6, 2018
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

Successfully merging this pull request may close these issues.

2 participants