Revision 60970
Added by Argiro Kokogiannaki almost 3 years ago
string-utils.class.ts | ||
---|---|---|
177 | 177 |
return identifiers; |
178 | 178 |
} |
179 | 179 |
|
180 |
public static getIdentifierFromString(pid: string): Identifier { |
|
180 |
public static getIdentifierFromString(pid: string,strict:boolean = true): Identifier {
|
|
181 | 181 |
if (Identifier.isValidDOI(pid)) { |
182 | 182 |
return {"class": "doi", "id": pid}; |
183 | 183 |
} else if (Identifier.isValidORCID(pid)) { |
... | ... | |
189 | 189 |
} else if (Identifier.isValidHANDLE(pid)) { |
190 | 190 |
return {"class": "handle", "id": pid}; |
191 | 191 |
} |
192 |
return null; |
|
192 |
//set it as a doi, to catch the case that doi has not valid format |
|
193 |
return (strict?null:{"class": "doi", "id": pid}); |
|
193 | 194 |
} |
194 | 195 |
|
195 | 196 |
public static getResultPIDFromIdentifiers(identifiers: Map<string, string[]>): Identifier { |
... | ... | |
210 | 211 |
} |
211 | 212 |
|
212 | 213 |
public static isValidDOI(str: string): boolean { |
213 |
var exp1 = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])\S)+)\b/g |
|
214 |
var exp2 = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])[[:graph:]])+)\b/g |
|
215 |
return (str.match(exp1) != null || str.match(exp2) != null); |
|
214 |
//keep only exp3? |
|
215 |
let exp1 = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])\S)+)\b/g; |
|
216 |
let exp2 = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])[[:graph:]])+)\b/g; |
|
217 |
let exp3 = /\b(10.*)\b/g; |
|
218 |
return (str.match(exp1) != null || str.match(exp2) != null || str.match(exp3) != null); |
|
216 | 219 |
} |
217 | 220 |
|
218 | 221 |
public static isValidORCID(str: string): boolean { |
Also available in: Unified diff
[Library|Trunk]
Checks for PIDs:
- Landing page, ORCID page: add looser rule for pids (if not valid set it is a doi)
- String utils: Identifier.isValidDOI add generic rule doi starting with "10."