feat!: remove url colon syntax

This commit is contained in:
2024-01-21 03:22:37 +02:00
committed by Chen Asraf
parent 5abf528b81
commit c6b185cd8f
2 changed files with 4 additions and 10 deletions

View File

@@ -88,14 +88,8 @@ export function parseConfigSelection(
key?: string,
): { configFile: string; key: string; isRemote: boolean } {
const isUrl = config.includes("://")
const hasColonToken = (!isUrl && config.includes(":")) || (isUrl && count(config, ":") > 1)
const colonIndex = config.lastIndexOf(":")
const [configFile, templateKey = "default"] = hasColonToken
? [config.substring(0, colonIndex), config.substring(colonIndex + 1)]
: [config, undefined]
const _key = (key ?? templateKey) || "default"
return { configFile, key: _key, isRemote: isUrl }
const _key = key || "default"
return { configFile: config, key: _key, isRemote: isUrl }
}
export function githubPartToUrl(part: string): string {

View File

@@ -72,7 +72,7 @@ describe("config", () => {
})
})
test("key override", () => {
expect(parseConfigSelection("scaffold.config.js:component", "main")).toEqual({
expect(parseConfigSelection("scaffold.config.js", "main")).toEqual({
configFile: "scaffold.config.js",
key: "main",
isRemote: false,
@@ -87,7 +87,7 @@ describe("config", () => {
})
test("isRemote: true", () => {
expect(
parseConfigSelection("https://github.com/chenasraf/simple-scaffold.git#scaffold.config.js:component", "main"),
parseConfigSelection("https://github.com/chenasraf/simple-scaffold.git#scaffold.config.js", "main"),
).toEqual({
configFile: "https://github.com/chenasraf/simple-scaffold.git#scaffold.config.js",
key: "main",