Skip to content

Commit

Permalink
Merge pull request #251 from salesforce/split-image-name-by-dots
Browse files Browse the repository at this point in the history
Split image name if there are dots
  • Loading branch information
afalko authored Jun 24, 2021
2 parents bdbf73c + a3419ac commit d38965c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class GitHubImageSearchTermList {
/**
* We need to split out search terms to accomodate how GitHub code search works
* We need to split out search terms to accommodate how GitHub code search works
* https://docs.github.com/en/github/searching-for-information-on-github/searching-code#considerations-for-code-search
*
* Essentially we'll split out any dashes in the registry domain and split out any url segments with dashes by
Expand Down Expand Up @@ -68,7 +68,17 @@ private static void processFinalUrlSegment(ProcessingState state, String finalIm
state.finalizeCurrentTerm();
}
state.addToCurrentTerm("/");
state.addToCurrentTerm(finalImageSegment);
if (finalImageSegment.contains(".")) {
String[] finalSegments = finalImageSegment.split("\\.");
for (int index = 0; index < finalSegments.length; index++) {
state.addToCurrentTerm(finalSegments[index]);
if (index < finalSegments.length - 1) {
state.finalizeCurrentTerm();
}
}
} else {
state.addToCurrentTerm(finalImageSegment);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public Object[][] imageAndParts() {
{"this-registry-has-dashes.some-company.with-dashes.io/rv-python-runtime", ImmutableList.of("FROM this", "registry", "has", "dashes.some", "company.with", "dashes.io/rv-python-runtime")},
{"this-registry-has-dashes.some-company.with-dashes.io/some-path/with-more-dashes/rv-python-runtime", ImmutableList.of("FROM this", "registry", "has", "dashes.some", "company.with", "dashes.io", "some-path", "with-more-dashes", "/rv-python-runtime")},
{"this-registry-has-dashes.some-company.with-dashes.io/somepath/with-more-dashes/rv-python-runtime", ImmutableList.of("FROM this", "registry", "has", "dashes.some", "company.with", "dashes.io/somepath", "with-more-dashes", "/rv-python-runtime")},
{"this-registry-has-dashes.some-company.with-dashes.io/somepath/with-more-dashes/rv-python-3.9-runtime", ImmutableList.of("FROM this", "registry", "has", "dashes.some", "company.with", "dashes.io/somepath", "with-more-dashes", "/rv-python-3", "9-runtime")},
{"this-registry-has-dashes.some-company.with-dashes.io/somepath/with-more-dashes/rv.python.3-9.runtime", ImmutableList.of("FROM this", "registry", "has", "dashes.some", "company.with", "dashes.io/somepath", "with-more-dashes", "/rv", "python", "3-9", "runtime")},
};
}

Expand Down

0 comments on commit d38965c

Please sign in to comment.