Skip to content
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

fix(nuxt): NuxtLink no default rel for relative external links #25600

Merged
merged 7 commits into from Feb 4, 2024

Conversation

harlan-zw
Copy link
Contributor

@harlan-zw harlan-zw commented Feb 3, 2024

πŸ”— Linked issue

Relates to #25532

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The default rel tag we apply to external NuxtLink's is quite interesting, here are some details about it if you don't know:

  • We have used it because this security issue: https://mathiasbynens.github.io/rel-noopener/
  • The noreferrer will automatically apply noopener, providing both are not required. I'd just use noreferrer but it's probably worth keeping consistency with larger sites in this case (i.e GitHub / Twitter still uses both).
  • The noopener has been applied by default when using target="_blank" in browsers since 2021, so providing all together will not be necessary at some point.

Anyway to the point of this PR, it's to fix an edge case where it's applied when not needed and document this logic.

<template>
  <NuxtLink to="/foo" external> <!--- <a href="/foo" rel="noopener noreferrer"> -->
</template>

Wasn't sure whether to support relative links that open in a separate window context for extra security, interested to hear others' thoughts (i.e you're hosting an untrusted app on your domain).

<template>
  <NuxtLink to="/naughty-app" external target="_blank"> <!--- <a to="/naughty-app" rel="noopener noreferrer"> -->
</template>

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

Copy link

stackblitz bot commented Feb 3, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

nuxt-studio bot commented Feb 3, 2024

βœ… Live Preview ready!

Name Edit Preview Latest Commit
Nuxt Docs Edit on Studio β†—οΈŽ View Live Preview fe47ed6

@harlan-zw harlan-zw changed the title fix(nuxt): apply default NuxtLink rel noreferrer to absolute urls fix(nuxt): NuxtLink no default rel for relative external links Feb 3, 2024
@danielroe danielroe merged commit b78e1cb into main Feb 4, 2024
36 checks passed
@danielroe danielroe deleted the fix/nuxt-link-rel branch February 4, 2024 22:21
@github-actions github-actions bot mentioned this pull request Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants