mirror of
https://github.com/tiennm99/blog.git
synced 2026-10-11 12:09:02 +00:00
fix(scripts): dedup URLs stored in markdown autolink form
The duplicate-check boundary set had '<' but not '>', so a URL stored as <https://…> (autolink, used by older posts) was never detected as a duplicate. Inherited from the JS engine; found while validating the Go port against 2020-era posts.
This commit is contained in:
1 parent
e8451d8c24
commit
c35a14f9bb
2 files changed
+18
-2
No files matched your search
@@ -196,7 +196,8 @@ func uuidBoundaryOK(text string, end int) bool {
|
||||
|
||||
// urlBoundaryOK: an optional trailing slash (bareURL strips it, stored URLs may
|
||||
// keep it), then a path/punctuation delimiter, whitespace, or end of text — so
|
||||
// /p/foo does not match a stored /p/foo-bar.
|
||||
// /p/foo does not match a stored /p/foo-bar. The '>' delimiter covers URLs
|
||||
// stored in markdown autolink form <https://…>, which older posts use.
|
||||
func urlBoundaryOK(text string, end int) bool {
|
||||
if end < len(text) && text[end] == '/' {
|
||||
end++
|
||||
@@ -208,7 +209,7 @@ func urlBoundaryOK(text string, end int) bool {
|
||||
case ' ', '\t', '\n', '\r', '\f', '\v':
|
||||
return true
|
||||
default:
|
||||
return strings.IndexByte(`)]"'?#<_&,`, c) != -1
|
||||
return strings.IndexByte(`)]"'?#<>_&,`, c) != -1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user