Word – URL encoded slash in URL failing in non-browser links

encodingmicrosoft wordurl

The website doi2bib.org looks up the DOI code for a publication and returns data about the publication. DOI codes include forward slashes, for example:

10.1037/dev0000663

There are two ways to get the data for that publication:

In the second method, the slash in the DOI must be URL encoded to %2f. The URL without that encoding does not work. Thus, https://doi2bib.org/bib/10.1037/dev0000663 does not work.

Now, here's the problem. If I copy the working URL

 https://doi2bib.org/bib/10.1037%2Fdev0000663

into MS Word or Excel, the link does not work from there, but yields the error message:

enter image description here

Note that the URL appears correctly in that error message. A clue to the problem might be in what appears when the mouse hovers over the URL in Word:

enter image description here

Note that here the URL has been decoded to change %2F to a slash. If that is the URL Word is actually trying to get to, that explains why it is failing.

I tried converting %2F to %252F to see if that would send the correct URL, but it doesn't. That yields the error message:

enter image description here

and hovering the URL suggests that Word just converted %252F also to a slash and then tried again to go to the wrong URL:

enter image description here

Besides Word and Excel, the links also do not work in the "Create PDF from Web Page" command of Adobe Acrobat. So the problem is not specific to MS Office programs.

How can I write this URL so Word and other programs will follow it correctly?

Best Answer

Workaround: Instead of DOI2bib, use CrossRef's metadata delivery (documentation: 1, 2). Bibliographic data can be returned in human-readable form using the basic metadata search, which can take the DOI either URL-encoded or not:

The above two URLs return the same result and both work in MS Word. Structured data can be returned in JSON format by using the ReST API (1, 2):

or in text by using link-based content negotiation, suffixing the above API URL with "/transform/application/x-bibtex":

or in XML by getting a free account and using its e-mail address in the OpenURL service (1, 2, 3) with the parameter setting "redirect=false" or "noredirect=true":

https://doi.crossref.org/openurl/?pid= < name@domain.com > &id=doi:10.1037/dev0000663&redirect=false

I'd still like to know if there's a proper solution to getting MS Word and other programs to request a URL without decoding %-codes. I won't accept my own answer here, so that I'll be able to accept a good answer if someone posts one.

Related Question