Skip to content

Route external link hrefs through a shared URL helper - #5615

Merged
obenland merged 3 commits into
mainfrom
share-link-href-util
Sep 10, 2026
Merged

obenland merged 3 commits into
mainfrom
share-link-href-util

Conversation

@obenland

Copy link
Copy Markdown
Member

Description

The attribution builder already normalised link URLs through a small private helper. This lifts that logic into a shared sanitizeHref util and reuses it in the shared VLink component so all external links go through the same URL handling instead of two slightly different paths.

  • Extract sanitizeHref to frontend/shared/utils/sanitize-href.ts (single source of truth; http/https/mailto pass through, other explicit schemes are normalised to about:blank, relative/scheme-less URLs untouched).
  • attribution-html.ts now imports it (behaviour unchanged).
  • VLink.vue applies it to external hrefs.

Internal (/…) links and normal http(s)/mailto links are unaffected; rendered output is identical for those.

Testing Instructions

  • cd frontend && pnpm test:unit sanitize-href v-link attribution-html
  • Detail pages, the reuse/attribution panel, and external links render and behave as before.

Checklist

  • Unit tests added and passing.
  • Lint passing.

🤖 Generated with Claude Code

Extract the href scheme handling from the attribution builder into a
shared `sanitizeHref` util and apply it in `VLink` for external links,
so both link paths normalise URLs the same way. Adds unit coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@obenland
obenland requested a review from a team as a code owner September 10, 2026 18:43
@obenland
obenland requested review from dhruvkb and obulat and a lite review from Copilot September 10, 2026 18:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@obenland obenland added 🧰 goal: internal improvement Improvement that benefits maintainers, not users 💻 aspect: code Concerns the software code in the repository 🟩 priority: low Low priority and doesn't need to be rushed 🐛 versioning: patch Patch version bump, associated with bug fix 🟨 tech: javascript Involves JavaScript labels Sep 10, 2026
@openverse-bot openverse-bot added the 🧱 stack: frontend Related to the Nuxt frontend label Sep 10, 2026
@openverse-bot openverse-bot moved this to 👀 Needs Review in Openverse PRs Sep 10, 2026
obenland and others added 2 commits September 10, 2026 13:52
Add cases for mixed-case schemes, control-character and whitespace
obfuscation, encoded (non-decoded) inputs, and a reactive prop update,
plus safe-URL regressions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Latest k6 run output1

     ✓ status was 200

     checks.........................: 100.00% ✓ 416      ✗ 0   
     data_received..................: 98 MB   407 kB/s
     data_sent......................: 132 kB  549 B/s
     http_req_blocked...............: avg=104.94µs min=2.4µs    med=5.27µs   max=3.21ms   p(90)=163.25µs p(95)=901.38µs
     http_req_connecting............: avg=54.26µs  min=0s       med=0s       max=2.43ms   p(90)=88.98µs  p(95)=130.67µs
     http_req_duration..............: avg=160.69ms min=19.49ms  med=102.38ms max=971.85ms p(90)=393.36ms p(95)=496.23ms
       { expected_response:true }...: avg=160.69ms min=19.49ms  med=102.38ms max=971.85ms p(90)=393.36ms p(95)=496.23ms
   ✓ http_req_failed................: 0.00%   ✓ 0        ✗ 416 
     http_req_receiving.............: avg=182.84µs min=54.79µs  med=156.68µs max=3.13ms   p(90)=256.27µs p(95)=307.2µs 
     http_req_sending...............: avg=27.33µs  min=8.32µs   med=24.52µs  max=116.68µs p(90)=42.85µs  p(95)=59.14µs 
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=160.48ms min=19.38ms  med=102.23ms max=971.53ms p(90)=393.09ms p(95)=495.98ms
     http_reqs......................: 416     1.725237/s
     iteration_duration.............: avg=864.56ms min=281.77ms med=914.16ms max=1.69s    p(90)=1.22s    p(95)=1.24s   
     iterations.....................: 78      0.323482/s
     vus............................: 3       min=0      max=6 
     vus_max........................: 60      min=60     max=60

Footnotes

  1. This comment will automatically update with new output each time k6 runs for this PR ↩

@obenland
obenland merged commit 8323a34 into main Sep 10, 2026
46 checks passed
@obenland
obenland deleted the share-link-href-util branch September 10, 2026 19:21
@github-project-automation github-project-automation Bot moved this from 👀 Needs Review to 🤝 Merged in Openverse PRs Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: frontend Related to the Nuxt frontend 🟨 tech: javascript Involves JavaScript 🐛 versioning: patch Patch version bump, associated with bug fix

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants