-
Notifications
You must be signed in to change notification settings - Fork 69
feat: link compared frameworks from the /compare pages #857
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4bf6878
feat: link compared frameworks from the /compare pages
vivek7405 274b2ee
fix: a11y cue, href escaping, and tests for compare outbound links
vivek7405 09815e4
fix: treat uppercase and protocol-relative URLs as external links
vivek7405 9dd189a
feat: make the compare outbound link visible, not hover-only
vivek7405 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /** | ||
| * Tests for the /compare outbound-link behavior (#856). | ||
| * | ||
| * Two surfaces: the shared markdown renderer's absolute-vs-internal link | ||
| * branching, and the compare [slug] page's competitor eyebrow link. Both | ||
| * open off-site links in a new tab with the site's screen-reader cue, and | ||
| * keep internal links navigating in place. | ||
| */ | ||
| import test from 'node:test'; | ||
| import assert from 'node:assert/strict'; | ||
| import { renderToString } from '@webjsdev/core/server'; | ||
| import { renderPostBody } from '#modules/blog/utils/render-post.ts'; | ||
| import ComparePage from '#app/compare/[slug]/page.ts'; | ||
|
|
||
| test('external markdown links open in a new tab with the a11y cue; internal links do not', () => { | ||
| const external = renderPostBody('See the [Remix 3 beta](https://remix.run/blog/remix-3-beta-preview).'); | ||
| assert.match(external, /href="https:\/\/remix\.run\/blog\/remix-3-beta-preview"/, 'keeps the external href'); | ||
| assert.match(external, /target="_blank"/, 'external link opens in a new tab'); | ||
| assert.match(external, /rel="noopener noreferrer"/, 'external link carries rel noopener noreferrer'); | ||
| assert.match(external, /\(opens in a new tab\)/, 'external link appends the screen-reader cue'); | ||
|
|
||
| // An uppercase scheme is still external (schemes are case-insensitive). | ||
| const upper = renderPostBody('[x](HTTPS://example.com)'); | ||
| assert.match(upper, /target="_blank"/, 'uppercase-scheme link is treated as external'); | ||
|
|
||
| // Counterfactual: an internal link must stay same-tab (no target/cue). | ||
| const internal = renderPostBody('Read the [docs](/docs).'); | ||
| assert.match(internal, /href="\/docs"/, 'keeps the internal href'); | ||
| assert.doesNotMatch(internal, /target="_blank"/, 'internal link stays in place'); | ||
| assert.doesNotMatch(internal, /opens in a new tab/, 'internal link gets no new-tab cue'); | ||
| }); | ||
|
|
||
| test('a double quote in a link URL cannot break out of the href attribute', () => { | ||
| const out = renderPostBody('[x](https://e.com/?q="bad")'); | ||
| assert.doesNotMatch(out, /\?q="bad"/, 'the raw quote is not emitted inside the attribute'); | ||
| assert.match(out, /%22/, 'the quote is percent-escaped in the href'); | ||
| }); | ||
|
|
||
| test('the compare page shows a visible outbound link to the competitor site in a new tab', async () => { | ||
| const out = await renderToString(await ComparePage({ params: { slug: 'webjs-vs-nextjs' } })); | ||
| // A visible, underlined "Visit the Next.js site" link (distinguishable while | ||
| // reading, not hover-only), pointing at nextjs.org, new tab, with the cue. | ||
| assert.match(out, /<a href="https:\/\/nextjs\.org"[^>]*target="_blank"[^>]*rel="noopener noreferrer"[^>]*class="[^"]*underline/, 'renders an underlined outbound link'); | ||
| assert.match(out, /Visit the Next\.js site/, 'the link is clearly labeled'); | ||
| assert.match(out, /\(opens in a new tab\)/, 'the outbound link carries the screen-reader cue'); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.