Skip to content

Commit

Permalink
Merge pull request #128 from snyk/fix/strip-off-v-prefix-from-cocoapods
Browse files Browse the repository at this point in the history
fix: strip off version prefix when parsing CocoaPods paths
  • Loading branch information
jacek-rzrz authored Nov 28, 2024
2 parents 64ec1f2 + 81acf38 commit 186718f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public static Optional<CocoapodsPackage> parse(
}

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

if (nameVersion.length != 2) {
LOG.warn("Unexpected Cocoapods package name: {}", artifactoryPackageName);
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 186718f

Please sign in to comment.