Skip to content

Commit a1cc810

Browse files
committed
ignore mailto links
1 parent 3f8849e commit a1cc810

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

scripts/check_relative_links.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@ def extract_relative_links(file_path: str) -> List[Tuple[str, int, str]]:
3535
lines = file.readlines()
3636

3737
# Regular expressions for different types of markdown links
38-
# Only match relative links that don't start with http/https/ftp
38+
# Only match relative links that don't start with http/https/ftp/mailto
3939
inline_link_pattern = re.compile(
40-
r"\[(?:[^\]]+)\]\(((?!https?:|ftp:)[^)]+)\)"
40+
r"\[(?:[^\]]+)\]\(((?!https?:|ftp:|mailto:)[^)]+)\)"
4141
)
4242
reference_link_def_pattern = re.compile(
43-
r"^\s*\[(?:[^\]]+)\]:\s*((?!https?:|ftp:)\S+)"
43+
r"^\s*\[(?:[^\]]+)\]:\s*((?!https?:|ftp:|mailto:)\S+)"
4444
)
4545
html_link_pattern = re.compile(
46-
r'<a\s+(?:[^>]*?)href=["\']((?!https?:|ftp:).*?)["\']', re.IGNORECASE
46+
r'<a\s+(?:[^>]*?)href=["\']((?!https?:|ftp:|mailto:).*?)["\']',
47+
re.IGNORECASE,
4748
)
4849

4950
for line_num, line in enumerate(lines, 1):
@@ -157,6 +158,7 @@ def check_relative_links(dir_path: str) -> bool:
157158
".svg",
158159
"assets",
159160
".gitbook",
161+
"mailto:",
160162
]
161163
):
162164
continue

0 commit comments

Comments
 (0)