From e89c18578cfe629e03f46b487cde77e0eeea1524 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Sun, 19 Feb 2023 19:33:59 +0100 Subject: [PATCH] Optimize stringToTerm for named nodes --- lib/TermUtil.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/TermUtil.ts b/lib/TermUtil.ts index 1831fca..cb2f886 100644 --- a/lib/TermUtil.ts +++ b/lib/TermUtil.ts @@ -107,7 +107,7 @@ export function stringToTerm(value: string | undefined, dataFactory?: RDF.DataFa return dataFactory.literal(getLiteralValue(value), language || type); case '<': default: - if (value.startsWith('<<') && value.endsWith('>>')) { + if (value[0] === '<' && value.length > 4 && value[1] === '<' && value[value.length - 1] === '>' && value[value.length - 2] === '>') { // Iterate character-by-character to detect spaces that are *not* wrapped in <<>> const terms = value.slice(2, -2).trim(); let stringTerms: string[] = [];