Skip to content

Commit

Permalink
global: fix DOI unicode issues
Browse files Browse the repository at this point in the history
* Handles unicode characters in DOI.

* URL-encodes generated DOI URLs
  • Loading branch information
slint authored and lnielsen committed Nov 22, 2017
1 parent a62bf1a commit 84ab6fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
21 changes: 11 additions & 10 deletions idutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import re

from isbn import ISBN
from six.moves.urllib.parse import urlparse
from six.moves.urllib.parse import urlparse, quote_plus


from .version import __version__

Expand Down Expand Up @@ -501,15 +502,15 @@ def normalize_pid(val, scheme):


LANDING_URLS = {
'doi': 'https://doi.org/{pid}',
'handle': '{scheme}://hdl.handle.net/{pid}',
'arxiv': '{scheme}://arxiv.org/abs/{pid}',
'orcid': '{scheme}://orcid.org/{pid}',
'pmid': '{scheme}://www.ncbi.nlm.nih.gov/pubmed/{pid}',
'ads': 'http://adsabs.harvard.edu/abs/{pid}',
'pmcid': '{scheme}://www.ncbi.nlm.nih.gov/pmc/{pid}',
'gnd': 'http://d-nb.info/gnd/{pid}',
'urn': '{scheme}://nbn-resolving.org/{pid}',
'doi': u'https://doi.org/{pid}',
'handle': u'{scheme}://hdl.handle.net/{pid}',
'arxiv': u'{scheme}://arxiv.org/abs/{pid}',
'orcid': u'{scheme}://orcid.org/{pid}',
'pmid': u'{scheme}://www.ncbi.nlm.nih.gov/pubmed/{pid}',
'ads': u'http://adsabs.harvard.edu/abs/{pid}',
'pmcid': u'{scheme}://www.ncbi.nlm.nih.gov/pmc/{pid}',
'gnd': u'http://d-nb.info/gnd/{pid}',
'urn': u'{scheme}://nbn-resolving.org/{pid}',
}
"""URL generation configuration for the supported PID providers."""

Expand Down
9 changes: 9 additions & 0 deletions tests/test_idutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@
('doi.org/10.1016/j.epsl.2011.11.037', ['doi', 'handle'],
'10.1016/j.epsl.2011.11.037',
'https://doi.org/10.1016/j.epsl.2011.11.037'),
(u'10.1016/üникóδé-дôΐ', ['doi', 'handle'],
u'10.1016/üникóδé-дôΐ', u'https://doi.org/10.1016/üникóδé-дôΐ'),
(u'10.1016/སྦ་བཞེད་', ['doi', 'handle'],
u'10.1016/སྦ་བཞེད་', u'https://doi.org/10.1016/སྦ་བཞེད་'),
('10.1002/(SICI)1521-3978(199806)46:4/5<493::AID-PROP493>3.0.CO;2-P',
['doi', 'handle'],
'10.1002/(SICI)1521-3978(199806)46:4/5<493::AID-PROP493>3.0.CO;2-P',
('https://doi.org/'
'10.1002/(SICI)1521-3978(199806)46:4/5<493::AID-PROP493>3.0.CO;2-P')),
('9783468111242', ['isbn', 'ean13'], '978-3-468-11124-2', ''),
('4006381333931', ['ean13'], '', ''),
('73513537', ['ean8'], '', ''),
Expand Down

0 comments on commit 84ab6fa

Please sign in to comment.