Mvolz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/189217

Change subject: Fix: anchor PMC and PMCIDs to beginning of string
......................................................................

Fix: anchor PMC and PMCIDs to beginning of string

The regex for PMC and PMCID2 would match word
boundries followed by 8 or 7 digits respectively.
This would cause URLs with lengths of digits
seperated by non alphnumeric characters to match,
for instance, examples.com/1234567 or
example.com/x.12345678.x.

Bug: T88898
Change-Id: I5aa49f9ca3cea6ba380d4bd8224e914b74b43316
---
M lib/distinguish.js
1 file changed, 3 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/citoid 
refs/changes/17/189217/1

diff --git a/lib/distinguish.js b/lib/distinguish.js
index aaab664..a6e866d 100644
--- a/lib/distinguish.js
+++ b/lib/distinguish.js
@@ -27,9 +27,9 @@
        search = searchString;
 
        reDOI = new RegExp('\\b10[.][0-9]{4,}[//].*\\b');
-       rePMID = new RegExp('\\b\\d{8}\\b');
+       rePMID = new RegExp('^\\d{8}\\b');
        rePMCID = new RegExp('\\bPMC\\d{7}\\b');
-       rePMCID2 = new RegExp('\\b\\d{7}\\b');
+       rePMCID2 = new RegExp('^\\d{7}\\b');
 
        matchDOI = search.match(reDOI);
        matchPMID = search.match(rePMID);
@@ -49,10 +49,8 @@
                        parsedURL = urlParse.parse(search);
                        if (!parsedURL.protocol){
                                search = 'http://'+ search;
-                               callback(search, requestFromURL);
-                       } else {
-                               callback(search, requestFromURL); //assume url 
if not doi
                        }
+                       callback(search, requestFromURL); //assume url if not 
doi
                }
        }
 };

-- 
To view, visit https://gerrit.wikimedia.org/r/189217
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5aa49f9ca3cea6ba380d4bd8224e914b74b43316
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/citoid
Gerrit-Branch: master
Gerrit-Owner: Mvolz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to