Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt): check before appending comma in composable keys#8529

Merged
pi0 merged 2 commits intomainfrom
fix/comma-grenade
Nov 2, 2022
Merged

fix(nuxt): check before appending comma in composable keys#8529
pi0 merged 2 commits intomainfrom
fix/comma-grenade

Conversation

@danielroe
Copy link
Member

🔗 Linked issue

resolves nuxt/nuxt#15272

❓ 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

We were previously not confirming whether there was a trailing comma before appending our own.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added bug Something isn't working 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage labels Oct 27, 2022
@danielroe danielroe requested a review from pi0 October 27, 2022 13:40
@danielroe danielroe self-assigned this Oct 27, 2022
@codesandbox
Copy link

codesandbox bot commented Oct 27, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@netlify
Copy link

netlify bot commented Oct 27, 2022

Deploy Preview for nuxt3-docs canceled.

Name Link
🔨 Latest commit 4abf359
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/6362431346db760008dfb0c9

break
}

const endsWithComma = code.slice(codeIndex + (node as any).start, codeIndex + (node as any).end - 1).trim().endsWith(',')
Copy link
Member

@pi0 pi0 Nov 2, 2022

Choose a reason for hiding this comment

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

Perf: this is a heavy operation to run on each code block, copying the whole string, trimming (that also copies) to only check the last character is ,. We could replace it with a look-behind loop.

Suggested change
const endsWithComma = code.slice(codeIndex + (node as any).start, codeIndex + (node as any).end - 1).trim().endsWith(',')
// TODO: Optimize me (https://github.com/nuxt/framework/pull/8529)
const endsWithComma = code.slice(codeIndex + (node as any).start, codeIndex + (node as any).end - 1).trim().endsWith(',')

@pi0 pi0 merged commit f485c14 into main Nov 2, 2022
@pi0 pi0 deleted the fix/comma-grenade branch November 2, 2022 10:15
@pi0 pi0 mentioned this pull request Nov 3, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.x bug Something isn't working 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useAsyncData with comma breaks

2 participants