From f537920702a51fe5590c20cfc307dade7e0eff55 Mon Sep 17 00:00:00 2001 From: argirok Date: Fri, 1 Dec 2023 16:16:25 +0200 Subject: [PATCH 1/2] [ DONE | ADDED] String utils - Identifiers: consider valid ORCID the full url, add getRawORCID method --- utils/string-utils.class.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/utils/string-utils.class.ts b/utils/string-utils.class.ts index dff363ff..1f24592f 100644 --- a/utils/string-utils.class.ts +++ b/utils/string-utils.class.ts @@ -193,7 +193,7 @@ export class Identifier { pid = Identifier.getRawDOIValue(pid); return {"class": "doi", "id": pid}; } else if (Identifier.isValidORCID(pid)) { - return {"class": "ORCID", "id": pid}; + return {"class": "ORCID", "id": Identifier.getRawORCID(pid)}; } else if (Identifier.isValidPMCID(pid)) { return {"class": "pmc", "id": pid}; } else if (Identifier.isValidPMID(pid)) { @@ -236,9 +236,15 @@ export class Identifier { public static isValidORCID(str: string): boolean { let exp = /\b\d{4}-\d{4}-\d{4}-(\d{3}X|\d{4})\b/g; - return str.match(exp) != null; + return str.match(exp) != null || this.getRawORCID(str).match(exp) != null; + } + public static getRawORCID(id: string): string { + if(id.indexOf("orcid.org")!=-1 && id.split("orcid.org/").length > 1){ + id = id.split("orcid.org/")[1]; + } + return id; + } - public static isValidPMID(str: string): boolean { let exp = /^\d*$/g; return str.match(exp) != null; From 6daf729374eb0768a3ad510eda3491db1b06a1ca Mon Sep 17 00:00:00 2001 From: argirok Date: Fri, 1 Dec 2023 17:13:16 +0200 Subject: [PATCH 2/2] [develop | DONE | CHANGED] : String utils - urlPrefix add check in case url is null --- utils/string-utils.class.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/string-utils.class.ts b/utils/string-utils.class.ts index 1f24592f..f71cdc3e 100644 --- a/utils/string-utils.class.ts +++ b/utils/string-utils.class.ts @@ -284,7 +284,7 @@ export class StringUtils { public static jsonRegex = /^[\],:{}\s]*$/; public static urlPrefix(url: string): string { - if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("//")) { + if (!url || url.startsWith("http://") || url.startsWith("https://") || url.startsWith("//")) { return ""; } else { return "//";