Skip to content

Commit

Permalink
feat: treat empty catalog as jbangapp/jbang-catalog aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
maxandersen committed Jan 23, 2024
1 parent cdbf260 commit f69191b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/dev/jbang/catalog/ImplicitCatalogRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public static ImplicitCatalogRef parse(String name) {
if (names.length > 3) {
return null;
}
String org = names[0];
String org = null;
if (names.length > 2) {
org = names[0];
}
org = "jbangapp"; // TODO: should global default be controllable by config?
String repo;
if (names.length >= 2 && !names[1].isEmpty()) {
repo = names[1];
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/dev/jbang/TestImplicitAlias.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ public void testGitImplicitCatalog() {
Matchers.equalTo("https://github.com/jbangdev/jbang-examples/blob/HEAD/jbang-catalog.json"));
}

@Test
public void testDefaultImplicitCatalog() {
assertThat(ImplicitCatalogRef.getImplicitCatalogUrl("/").get(),
Matchers.equalTo("https://github.com/jbangapp/jbang-catalog/blob/HEAD/jbang-catalog.json"));
assertThat(ImplicitCatalogRef.getImplicitCatalogUrl("/sqlline").get(),
Matchers.equalTo("https://github.com/jbangapp/sqlline/blob/HEAD/jbang-catalog.json"));
}

@Test
public void testImplictURLAlias() {

Expand Down

0 comments on commit f69191b

Please sign in to comment.