Skip to content

Commit

Permalink
Merge pull request #12 from cytopia/sanitize-trailing-parens
Browse files Browse the repository at this point in the history
Fix #11 Sanitize trailing parentheses
  • Loading branch information
cytopia authored Jul 31, 2018
2 parents 9ed5c6c + 7117376 commit 75ab4c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions linkcheck
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ STATUS_CODES=200
###
URL_REGEX="http(s)?:\\/\\/[-+%=?&():,._/#0-9a-zA-Z]+"

MY_VERSION="v0.5"
MY_VERSION="v0.6"


############################################################
Expand Down Expand Up @@ -144,7 +144,7 @@ setval() {
###
sanitize_url() {
local url="${1}"
local invalid="[,.!]$"
local invalid="[,.!\)]$"

# Remove any trailing garbage
while [[ ${url} =~ ${invalid} ]]; do
Expand Down
33 changes: 16 additions & 17 deletions tests/urls.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
# Plain URLs
https://nierautomata.wiki.fextralife.com/How+To+Unlock+the+Secret+Trophy+Shop
https://nierautomata.wiki.fextralife.com/Locked+Chests
https://www.baka-tsuki.org/project/?title=Ore_no_Im%C5%8Dto_ga_Konna_ni_Kawaii_Wake_ga_Nai
https://www.phoronix.com/scan.php?page=news_item&px=U2-NVMe-PCI-E-SSD-Adapter
https://en.wikipedia.org/w/index.php?title=Erlang_(programming_language)&diff=847224766&oldid=847107459
https://en.wiktionary.org/wiki/%E8%8C%B6

# Single Quoted URLs
'https://nierautomata.wiki.fextralife.com/How+To+Unlock+the+Secret+Trophy+Shop'
'https://nierautomata.wiki.fextralife.com/Locked+Chests'
'https://www.baka-tsuki.org/project/?title=Ore_no_Im%C5%8Dto_ga_Konna_ni_Kawaii_Wake_ga_Nai'
'https://www.phoronix.com/scan.php?page=news_item&px=U2-NVMe-PCI-E-SSD-Adapter'
'https://en.wikipedia.org/w/index.php?title=Erlang_(programming_language)&diff=847224766&oldid=847107459'
'https://en.wiktionary.org/wiki/%E8%8C%B6'

# Double Quoted URLs
"https://nierautomata.wiki.fextralife.com/How+To+Unlock+the+Secret+Trophy+Shop"
"https://nierautomata.wiki.fextralife.com/Locked+Chests"
"https://www.baka-tsuki.org/project/?title=Ore_no_Im%C5%8Dto_ga_Konna_ni_Kawaii_Wake_ga_Nai"
"https://www.phoronix.com/scan.php?page=news_item&px=U2-NVMe-PCI-E-SSD-Adapter"
"https://en.wikipedia.org/w/index.php?title=Erlang_(programming_language)&diff=847224766&oldid=847107459"
"https://en.wiktionary.org/wiki/%E8%8C%B6"

# Bracketed URLs
<https://nierautomata.wiki.fextralife.com/How+To+Unlock+the+Secret+Trophy+Shop>
<https://nierautomata.wiki.fextralife.com/Locked+Chests>
<https://www.baka-tsuki.org/project/?title=Ore_no_Im%C5%8Dto_ga_Konna_ni_Kawaii_Wake_ga_Nai>
<https://www.phoronix.com/scan.php?page=news_item&px=U2-NVMe-PCI-E-SSD-Adapter>
<https://en.wikipedia.org/w/index.php?title=Erlang_(programming_language)&diff=847224766&oldid=847107459>
<https://en.wiktionary.org/wiki/%E8%8C%B6>
<https://en.wiktionary.org/wiki/%E8%8C%B6>>

# Round Bracketed URLs
<https://www.phoronix.com/scan.php?page=news_item&px=U2-NVMe-PCI-E-SSD-Adapter)))
<https://en.wikipedia.org/w/index.php?title=Erlang_(programming_language)&diff=847224766&oldid=847107459)
<https://en.wiktionary.org/wiki/%E8%8C%B6))

# Curly Bracketed URLs
<https://www.phoronix.com/scan.php?page=news_item&px=U2-NVMe-PCI-E-SSD-Adapter}}}
<https://en.wikipedia.org/w/index.php?title=Erlang_(programming_language)&diff=847224766&oldid=847107459}
<https://en.wiktionary.org/wiki/%E8%8C%B6}}

# Square Bracketed URLs
<https://www.phoronix.com/scan.php?page=news_item&px=U2-NVMe-PCI-E-SSD-Adapter]
<https://en.wikipedia.org/w/index.php?title=Erlang_(programming_language)&diff=847224766&oldid=847107459]]
<https://en.wiktionary.org/wiki/%E8%8C%B6]

# Inline URLs with punctuation
https://nierautomata.wiki.fextralife.com/How+To+Unlock+the+Secret+Trophy+Shop,
https://nierautomata.wiki.fextralife.com/Locked+Chests!
https://www.baka-tsuki.org/project/?title=Ore_no_Im%C5%8Dto_ga_Konna_ni_Kawaii_Wake_ga_Nai.
https://www.phoronix.com/scan.php?page=news_item&px=U2-NVMe-PCI-E-SSD-Adapter,
https://en.wikipedia.org/w/index.php?title=Erlang_(programming_language)&diff=847224766&oldid=847107459!
https://en.wiktionary.org/wiki/%E8%8C%B6,

# Inline URLs with multiple punctuation
https://nierautomata.wiki.fextralife.com/How+To+Unlock+the+Secret+Trophy+Shop,.!
https://nierautomata.wiki.fextralife.com/Locked+Chests!.,
https://www.baka-tsuki.org/project/?title=Ore_no_Im%C5%8Dto_ga_Konna_ni_Kawaii_Wake_ga_Nai.,!
https://www.phoronix.com/scan.php?page=news_item&px=U2-NVMe-PCI-E-SSD-Adapter,.!
https://en.wikipedia.org/w/index.php?title=Erlang_(programming_language)&diff=847224766&oldid=847107459!.,
https://en.wiktionary.org/wiki/%E8%8C%B6,.!

0 comments on commit 75ab4c6

Please sign in to comment.