From 33aa33913cd6bb5269f0e5e115cead919013d3a0 Mon Sep 17 00:00:00 2001
From: Awraam
Date: Mon, 29 Sep 2025 19:31:22 +0200
Subject: [PATCH 1/2] fix: Make `www` case-sensitive when detecting link starts
---
src/rules.ts | 3 ++-
test/specs/new/autolinks.html | 8 +++++++-
test/specs/new/autolinks.md | 8 +++++++-
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/rules.ts b/src/rules.ts
index 67dcb09ece..8818819fdf 100644
--- a/src/rules.ts
+++ b/src/rules.ts
@@ -408,7 +408,8 @@ const inlineGfm: Record = {
...inlineNormal,
emStrongRDelimAst: emStrongRDelimAstGfm,
emStrongLDelim: emStrongLDelimGfm,
- url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i')
+ url: edit(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/)
+ .replace('protocol', /[fF][tT][pP]|[hH][tT][tT][pP][sS]?/)
.replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
.getRegex(),
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
diff --git a/test/specs/new/autolinks.html b/test/specs/new/autolinks.html
index 8fa4837e61..708f800c5e 100644
--- a/test/specs/new/autolinks.html
+++ b/test/specs/new/autolinks.html
@@ -12,4 +12,10 @@
me@example.com
-test@test.com
\ No newline at end of file
+test@test.com
+
+www.example.com
+
+Www.example.com
+
+WWW.example.com
diff --git a/test/specs/new/autolinks.md b/test/specs/new/autolinks.md
index 1f5f739c49..c77620cbff 100644
--- a/test/specs/new/autolinks.md
+++ b/test/specs/new/autolinks.md
@@ -12,4 +12,10 @@ hTtP://fOo.CoM
**me@example.com**
-__test@test.com__
\ No newline at end of file
+__test@test.com__
+
+www.example.com
+
+Www.example.com
+
+WWW.example.com
From 7646f3bd1c0c997353bc0fe1e6e8d4db5cf037a8 Mon Sep 17 00:00:00 2001
From: Awraam
Date: Fri, 3 Oct 2025 17:25:52 +0200
Subject: [PATCH 2/2] fix: Fix case-insensitive `http|ftp` in text
---
src/rules.ts | 4 +++-
test/specs/new/autolinks.html | 2 ++
test/specs/new/autolinks.md | 2 ++
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/rules.ts b/src/rules.ts
index 8818819fdf..e661bee4a3 100644
--- a/src/rules.ts
+++ b/src/rules.ts
@@ -414,7 +414,9 @@ const inlineGfm: Record = {
.getRegex(),
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\Www.example.com
WWW.example.com
+
+(See hTtPS://example.com/fhqwhgads.)
diff --git a/test/specs/new/autolinks.md b/test/specs/new/autolinks.md
index c77620cbff..e5e41fd761 100644
--- a/test/specs/new/autolinks.md
+++ b/test/specs/new/autolinks.md
@@ -19,3 +19,5 @@ www.example.com
Www.example.com
WWW.example.com
+
+(See hTtPS://example.com/fhqwhgads.)