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(prerender): only extract relative links #112

Merged
merged 4 commits into from
Apr 14, 2022
Merged

Conversation

atinux
Copy link
Member

@atinux atinux commented Apr 14, 2022

πŸ”— Linked issue

Related to https://github.com/nuxt/nuxt3-docs/issues/21

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 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)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The crawler should only extract the relative link. I don't know where to add a test case, I did test in the nuxt 3 upcoming docs and fixes the isssue.

πŸ“ Checklist

  • I have linked an issue or discussion.

@atinux atinux requested a review from pi0 April 14, 2022 16:19
src/prerender.ts Outdated
@@ -80,7 +80,9 @@ const LINK_REGEX = /href=['"]?([^'" >]+)/g
function extractLinks (html: string, _url: string) {
const links: string[] = []
for (const match of html.matchAll(LINK_REGEX)) {
links.push(parseURL(match[1]).pathname)
const url = parseURL(match[1])
// Extract only relative links
Copy link
Member

Choose a reason for hiding this comment

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

Currently we don't support relative links either (see _url above is unused)

Copy link
Member Author

Choose a reason for hiding this comment

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

What I meant is excluding the url that includes a host (external urls).

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the comment

@pi0
Copy link
Member

pi0 commented Apr 14, 2022

Added tests and an improvement to pass relative links as well.

@pi0 pi0 merged commit b61caf7 into main Apr 14, 2022
@pi0 pi0 deleted the fix/extract-relative-links branch April 14, 2022 17:41
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