Skip to content

fix: improve link fallback when OSC 8 is not supported #7294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025

Conversation

serhalp
Copy link
Member

@serhalp serhalp commented May 14, 2025

Summary

The terminal-link package uses OSC 8 link formatting when running in a terminal that supports it. When it isn't supported, by default it falls back to rendering the text followed by the link in parens. This is fine, but when we pass the full URL as the text, it's unnecessarily noisy, e.g.:

Deployed to draft URL: https://my-example-site.netlify.app (https://my-example-site.netlify.app)

Passing fallback: false toggles the fallback behaviour to just render the text as-is, e.g.:

Deployed to draft URL: https://my-example-site.netlify.app

This wasn't clear previously from the docs: sindresorhus/terminal-link#26.

Copy link

github-actions bot commented May 14, 2025

📊 Benchmark results

Comparing with 80652f6

  • Dependency count: 1,148 (no change)
  • Package size: 271 MB (no change)
  • Number of ts-expect-error directives: 397 (no change)

The `terminal-link` package uses [OSC 8](https://github.com/Alhadis/OSC8-Adoption/) link
formatting when running in a terminal that supports it. When it isn't supported, by
default it falls back to rendering the text followed by the link in parens. This is fine,
but when we pass the full URL as the text, it's unnecessarily noisy, e.g.:
https://example.com/foo/bar (https://example.com/foo/bar)

Passing `fallback: false` toggles the fallback behaviour to just render the text as-is.

This wasn't clear previously from the docs:
sindresorhus/terminal-link#26.
@serhalp serhalp force-pushed the fix/improve-fallback-terminal-link-formatting branch from 29c2337 to 95a6ac4 Compare May 14, 2025 13:13
@serhalp serhalp marked this pull request as ready for review May 14, 2025 14:04
@serhalp serhalp requested a review from a team as a code owner May 14, 2025 14:04
@serhalp serhalp merged commit 47242ce into main May 14, 2025
52 checks passed
@serhalp serhalp deleted the fix/improve-fallback-terminal-link-formatting branch May 14, 2025 18:16
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.

2 participants