Skip to content

Commit

Permalink
Merge pull request #2999 from digitalfabrik/bugfix/autolink-ignore-so…
Browse files Browse the repository at this point in the history
…ft-hyphens

Ignore soft hyphens when detecting links
  • Loading branch information
PeterNerlich authored Aug 15, 2024
2 parents 2ee4946 + 5ba5e46 commit 897ffbe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions integreat_cms/release_notes/current/unreleased/2998.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en: Ignore soft hyphens when detecting links
de: Ignoriere bedingte Trennstriche bei der Erkennung von Links
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

// constant values and magic numbers used below
const CHAR_CODE_SPACE = 160;
const CHAR_CODE_SOFT_HYPHEN = 173;
const NODE_TYPE_ELEMENT = 1;
const NODE_TYPE_TEXT = 3;
const MIN_RANGE_THRESHOLD = 5;
Expand Down Expand Up @@ -165,7 +166,7 @@
if (text.charAt(text.length - 1) === ".") {
setEnd(rng, endContainer, start - 1);
}
text = rng.toString().trim();
text = rng.toString().trim().replace(String.fromCharCode(CHAR_CODE_SOFT_HYPHEN), "");
const matches = text.match(autoLinkPattern);
const phoneMatches = text.match(/(0|\+)[0-9\-/]{6,20}/);
const protocol = getDefaultLinkProtocol(editor);
Expand Down

0 comments on commit 897ffbe

Please sign in to comment.