Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
public-apis
Commits
f921f4ec
Unverified
Commit
f921f4ec
authored
Aug 24, 2021
by
Matheus Felipe
Browse files
Filter the links after the index section
parent
60245abb
Changes
1
Hide whitespace changes
Inline
Side-by-side
build/validate_links.py
View file @
f921f4ec
...
...
@@ -14,12 +14,19 @@ ignored_links = [
def
parse_links
(
filename
):
"""Returns a list of URLs from text file"""
with
open
(
filename
)
as
fp
:
data
=
fp
.
read
()
with
open
(
filename
,
mode
=
'r'
,
encoding
=
'utf-8'
)
as
fp
:
readme
=
fp
.
read
()
index_section
=
readme
.
find
(
'## Index'
)
content
=
readme
[
index_section
:]
raw_links
=
re
.
findall
(
'((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:
\'\"
.,<>?«»“”‘’]))'
,
data
)
links
=
[
raw_link
[
0
]
for
raw_link
in
raw_links
]
content
)
links
=
[
str
(
raw_link
[
0
]).
rstrip
(
'/'
)
for
raw_link
in
raw_links
]
return
links
def
dup_links
(
links
):
...
...
@@ -30,7 +37,6 @@ def dup_links(links):
dupes
=
[]
for
link
in
links
:
link
=
link
.
rstrip
(
'/'
)
if
link
in
ignored_links
:
continue
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment