Skip to content

fix: do not treat empty href quotes as URLs#143

Open
santhreal wants to merge 1 commit into
adbar:masterfrom
santhreal:fix/extract-links-empty-href
Open

fix: do not treat empty href quotes as URLs#143
santhreal wants to merge 1 commit into
adbar:masterfrom
santhreal:fix/extract-links-empty-href

Conversation

@santhreal

Copy link
Copy Markdown
Contributor

extract_links turns an empty single-quoted href into a fake path. LINK_REGEX required at least one character inside the quotes, so for href='' it captured the closing quote and check_url normalized that to /%27.

Empty hrefs should resolve like other relative links (to the page URL). Allow an empty match in LINK_REGEX.

from courlan import extract_links
extract_links("<html><a href=''>x</a></html>", "https://example.org")
# was {'https://example.org/%27'}

LINK_REGEX required at least one href character, so href='' captured the
closing quote and extract_links emitted paths like /%27. Allow empty
matches so empty hrefs resolve to the page URL like other relatives.
@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.77%. Comparing base (6f0f507) to head (86951ff).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #143   +/-   ##
=======================================
  Coverage   99.77%   99.77%           
=======================================
  Files          14       14           
  Lines         905      905           
  Branches      173      173           
=======================================
  Hits          903      903           
  Misses          2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant