From 820effc79cef3d15e636e16bdfc0d17647c799be Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Wed, 13 Nov 2024 16:13:55 +0000 Subject: [PATCH] Fix DOI and URL parsing regression when the last character is missing --- src/core/module/link/parsed-overlays.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/module/link/parsed-overlays.js b/src/core/module/link/parsed-overlays.js index b223b53f2bb005..b7d191af0618fd 100644 --- a/src/core/module/link/parsed-overlays.js +++ b/src/core/module/link/parsed-overlays.js @@ -52,7 +52,7 @@ export function getParsedOverlays(chars) { let match = text.match(urlRegExp); if (match) { let from = sequence.from + match.index; - let to = from + match[0].length - 1; + let to = from + match[0].length; let url = chars.slice(from, to).map(x => x.c).join(''); if (url.includes('@')) { continue; @@ -63,7 +63,7 @@ export function getParsedOverlays(chars) { match = text.match(doiRegExp); if (match) { let from = sequence.from + match.index; - let to = from + match[0].length - 1; + let to = from + match[0].length; let doi = chars.slice(from, to).map(x => x.c).join(''); let url = 'https://doi.org/' + encodeURIComponent(doi); links.push({ from, to, text: doi, url });