Skip to content

Commit d0aa93d

Browse files
authored
Merge pull request #9 from katrinleinweber/broaden-DOI-regex
Broaden reg-ex to all resolver variants
2 parents bba7179 + 4296796 commit d0aa93d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ doi.declared = function (opts) {
5050

5151
doi.resolvePath = function (opts) {
5252
opts = opts || {}
53-
return opts.protocol ? new RegExp('^http(s)?\\://dx\\.doi\\.org/' + doiRegex + '$') :
54-
new RegExp('^(http(s)?\\://)?dx\\.doi\\.org/' + doiRegex + '$')
53+
return opts.protocol ? new RegExp('^http(s)?\\://(dx\\.)?doi\\.org/' + doiRegex + '$') :
54+
new RegExp('^(http(s)?\\://)?(dx\\.)?doi\\.org/' + doiRegex + '$')
5555
}

spec/test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ var doiDeclared = [
2323
]
2424

2525
var doiResolvePathWithoutProtocol = [
26-
'dx.doi.org/10.1016/j.neuron.2014.09.004'
26+
'dx.doi.org/10.1016/j.neuron.2014.09.004',
27+
'doi.org/10.1016/j.neuron.2014.09.004'
2728
]
2829

2930
var doiResolvePathWithProtocol = [
3031
'http://dx.doi.org/10.1016/j.neuron.2014.09.004',
31-
'https://dx.doi.org/10.1016/j.neuron.2014.09.004'
32+
'https://dx.doi.org/10.1016/j.neuron.2014.09.004',
33+
'http://doi.org/10.1016/j.neuron.2014.09.004',
34+
'https://doi.org/10.1016/j.neuron.2014.09.004'
3235
]
3336

3437
var doiResolvePathInvalid = [
@@ -37,7 +40,9 @@ var doiResolvePathInvalid = [
3740

3841
var doiResolvePathWithProtocolInvalid = [
3942
'httpp://dx.doi.org/10.1016/j.neuron.2014.09.004',
43+
'httpp://doi.org/10.1016/j.neuron.2014.09.004',
4044
'ftp://dx.doi.org/10.1016/j.neuron.2014.09.004',
45+
'ftp://doi.org/10.1016/j.neuron.2014.09.004',
4146
]
4247

4348
var doiNotDeclared = [

0 commit comments

Comments
 (0)