Skip to content

Commit

Permalink
fix: strip off version prefix when parsing CocoaPods paths
Browse files Browse the repository at this point in the history
For artifacts coming with a `v` prefix in the artifactory path,
e.g. `libwebp-v1.3.0.tar.gz`, the parsed version number should skip the
prefix i.e. it should be `1.3.0` and not `v1.3.0`.
  • Loading branch information
jacek-rzrz committed Nov 27, 2024
1 parent 64ec1f2 commit ddf6b12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static Optional<CocoapodsPackage> parse(
}

String[] nameVersion = artifactoryPackageName.replace(".tar.gz", "")
.replaceFirst("(?s)-(?!.*?-)", "!")
.replaceFirst("(?s)-[a-zA-Z]*(?!.*?-)", "!")
.split("!");

if (nameVersion.length != 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ void parse() {
assertThat(pckg.get().getVersion()).isEqualTo("1.9.1");
}

@Test
void parse_whenVersionNumberHasVPrefix() {
Optional<CocoapodsPackage> pckg = CocoapodsPackage.parse(
"libwebp-v1.3.0.tar.gz"
);

assertThat(pckg).isNotEmpty();
assertThat(pckg.get().getName()).isEqualTo("libwebp");
assertThat(pckg.get().getVersion()).isEqualTo("1.3.0");
}

@Test
void parse_unexpectedPackageName() {
assertThat(CocoapodsPackage.parse("3.5.1.tar.gz")).isEmpty();
Expand Down

0 comments on commit ddf6b12

Please sign in to comment.