From 15f6fe097b5c6d272c942ee5863485ce85f0fb8c Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Mon, 27 May 2024 09:16:22 +0200 Subject: [PATCH] fix: allow scope to start with number --- src/utils.ts | 4 ++-- test/utils.test.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index a83fcb0..2c6670d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -14,8 +14,8 @@ export function logDebug(msg: string) { } } -const EXTRACT_REG = /^@([a-z][a-z0-9-]+)\/([a-z0-9-]+)(@(.+))?$/; -const EXTRACT_REG_PROXY = /^@jsr\/([a-z][a-z0-9-]+)__([a-z0-9-]+)(@(.+))?$/; +const EXTRACT_REG = /^@([a-z0-9-]+)\/([a-z0-9-]+)(@(.+))?$/; +const EXTRACT_REG_PROXY = /^@jsr\/([a-z0-9-]+)__([a-z0-9-]+)(@(.+))?$/; export class JsrPackageNameError extends Error {} diff --git a/test/utils.test.ts b/test/utils.test.ts index 74f7488..9e712ef 100644 --- a/test/utils.test.ts +++ b/test/utils.test.ts @@ -3,6 +3,7 @@ import * as path from "node:path"; import { runInTempDir } from "./test_utils"; import { findProjectDir, + JsrPackage, PkgJson, writeJson, writeTextFile, @@ -94,3 +95,10 @@ describe("findProjectDir", () => { }); }); }); + +describe("JsrPackage", () => { + it("should allow scopes starting with a number", () => { + JsrPackage.from("@0abc/foo"); + JsrPackage.from("@jsr/0abc__foo"); + }); +});