Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit 97de1c3

Browse files
committed
Merge branch 'v1.3' of https://github.com/doecode/server into v1.3
2 parents cbfadfc + 5b562dd commit 97de1c3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/gov/osti/services/Validation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public class Validation {
112112
protected static final Pattern EMAIL_PATTERN = Pattern.compile("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
113113
protected static final Pattern URL_PATTERN = Pattern.compile("\\bhttps?://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]");
114114
protected static final Pattern DOI_PATTERN = Pattern.compile("10.\\d{4,9}/[-._;()/:A-Za-z0-9]+$");
115-
protected static final Pattern ORCID_PATTERN = Pattern.compile("(?i)^\\s*(?:(?:https?:\\/\\/)?orcid\\.org\\/)?(\\d{4}(?:-?\\d{4}){3})\\s*$");
115+
protected static final Pattern ORCID_PATTERN = Pattern.compile("(?i)^\\s*(?:(?:https?:\\/\\/)?orcid\\.org\\/)?(\\d{4}(?:-?\\d{4}){2}(?:-?\\d{3}[\\dX]))\\s*$");
116116

117117
@JsonIgnoreProperties (ignoreUnknown = true)
118118
private static class ValidationRequest implements Serializable {
@@ -193,7 +193,7 @@ private static String stripBaseORCID(String value) {
193193

194194
if (matcher.find())
195195
// return matching 16 digit characters
196-
return matcher.group(1).replaceAll("-", "");
196+
return matcher.group(1).replaceAll("-", "").replaceAll("x", "X");
197197
else
198198
// no valid ORCID pattern
199199
return null;

src/test/java/gov/osti/services/ValidationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void testIsValidORCID() {
145145
};
146146
// valid DOI patterns
147147
String[] valid = { "0000000218250097", "0000-0003-3348-0736",
148-
"HTTPS://orcid.org/0000-0001-8811-2688", " 00000003-33480736 "
148+
"HTTPS://orcid.org/0000-0001-8811-2688", " 00000002-5667291x "
149149
};
150150

151151
for ( String orcid : invalid ) {

0 commit comments

Comments
 (0)