summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Mohammed Elhaouari <m@codiume.com> 2022-09-20 17:36:40 +0100
committerGravatar GitHub <noreply@github.com> 2022-09-20 12:36:40 -0400
commita49bc2f02e8fa6c3e26e73d28a1c9c0e40da082a (patch)
tree66839021829756b8de7b14a1eacd04f2836e431c
parent91568bb055c7e8d561232ddc6d10520fbf647e61 (diff)
downloadastro-a49bc2f02e8fa6c3e26e73d28a1c9c0e40da082a.tar.gz
astro-a49bc2f02e8fa6c3e26e73d28a1c9c0e40da082a.tar.zst
astro-a49bc2f02e8fa6c3e26e73d28a1c9c0e40da082a.zip
Fix extra slash when adding integrations that ends with `/astro` (#4817)
* fix toIdent util * add changesets
-rw-r--r--.changeset/lovely-seals-compare.md5
-rw-r--r--packages/astro/src/core/add/index.ts3
2 files changed, 7 insertions, 1 deletions
diff --git a/.changeset/lovely-seals-compare.md b/.changeset/lovely-seals-compare.md
new file mode 100644
index 000000000..667b932cf
--- /dev/null
+++ b/.changeset/lovely-seals-compare.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+fix parsing integration names with astro add command
diff --git a/packages/astro/src/core/add/index.ts b/packages/astro/src/core/add/index.ts
index 70a766e07..0f4e387ed 100644
--- a/packages/astro/src/core/add/index.ts
+++ b/packages/astro/src/core/add/index.ts
@@ -304,11 +304,12 @@ async function parseAstroConfig(configURL: URL): Promise<t.File> {
// - 123numeric => numeric
// - @npm/thingy => npmThingy
// - @jane/foo.js => janeFoo
+// - @tokencss/astro => tokencss
const toIdent = (name: string) => {
const ident = name
.trim()
// Remove astro or (astrojs) prefix and suffix
- .replace(/[-_\.]?astro(?:js)?[-_\.]?/g, '')
+ .replace(/[-_\.\/]?astro(?:js)?[-_\.]?/g, '')
// drop .js suffix
.replace(/\.js/, '')
// convert to camel case