Fix extra slash when adding integrations that ends with /astro (#4817)

* fix toIdent util

* add changesets
This commit is contained in:
Mohammed Elhaouari 2022-09-20 17:36:40 +01:00 committed by GitHub
parent 91568bb055
commit a49bc2f02e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
fix parsing integration names with astro add command

View file

@ -304,11 +304,12 @@ async function parseAstroConfig(configURL: URL): Promise<t.File> {
// - 123numeric => numeric // - 123numeric => numeric
// - @npm/thingy => npmThingy // - @npm/thingy => npmThingy
// - @jane/foo.js => janeFoo // - @jane/foo.js => janeFoo
// - @tokencss/astro => tokencss
const toIdent = (name: string) => { const toIdent = (name: string) => {
const ident = name const ident = name
.trim() .trim()
// Remove astro or (astrojs) prefix and suffix // Remove astro or (astrojs) prefix and suffix
.replace(/[-_\.]?astro(?:js)?[-_\.]?/g, '') .replace(/[-_\.\/]?astro(?:js)?[-_\.]?/g, '')
// drop .js suffix // drop .js suffix
.replace(/\.js/, '') .replace(/\.js/, '')
// convert to camel case // convert to camel case