[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."



git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60970 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2021-04-26 09:42:41 +00:00
parent 336f85aa97
commit e34c5d4daa
3 changed files with 10 additions and 7 deletions

View File

@ -154,7 +154,7 @@ export class ResultLandingComponent {
this.id = data["id"];
this.initMetaAndLinks("result");
} else if (data["pid"]) {
this.identifier = Identifier.getIdentifierFromString(decodeURIComponent(data["pid"]));
this.identifier = Identifier.getIdentifierFromString(decodeURIComponent(data["pid"]),false);
if(!this.type) {
this.type = "result";

View File

@ -281,7 +281,7 @@ export class MyOrcidLinksComponent {
for(let work of works) {
for(let pid of work['pids']) {
let identifier: Identifier = Identifier.getIdentifierFromString(pid);
let identifier: Identifier = Identifier.getIdentifierFromString(pid, false);
this.orcidQuery += (this.orcidQuery ? " or " : "") + ('(pidclassid exact "'+identifier.class+'" and pid="'+StringUtils.URIEncode(identifier.id)+'")');
}
}

View File

@ -177,7 +177,7 @@ export class Identifier {
return identifiers;
}
public static getIdentifierFromString(pid: string): Identifier {
public static getIdentifierFromString(pid: string,strict:boolean = true): Identifier {
if (Identifier.isValidDOI(pid)) {
return {"class": "doi", "id": pid};
} else if (Identifier.isValidORCID(pid)) {
@ -189,7 +189,8 @@ export class Identifier {
} else if (Identifier.isValidHANDLE(pid)) {
return {"class": "handle", "id": pid};
}
return null;
//set it as a doi, to catch the case that doi has not valid format
return (strict?null:{"class": "doi", "id": pid});
}
public static getResultPIDFromIdentifiers(identifiers: Map<string, string[]>): Identifier {
@ -210,9 +211,11 @@ export class Identifier {
}
public static isValidDOI(str: string): boolean {
var exp1 = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])\S)+)\b/g
var exp2 = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])[[:graph:]])+)\b/g
return (str.match(exp1) != null || str.match(exp2) != null);
//keep only exp3?
let exp1 = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])\S)+)\b/g;
let exp2 = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])[[:graph:]])+)\b/g;
let exp3 = /\b(10.*)\b/g;
return (str.match(exp1) != null || str.match(exp2) != null || str.match(exp3) != null);
}
public static isValidORCID(str: string): boolean {