Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #309 from mmaeller/#308
Browse files Browse the repository at this point in the history
#308 Extend repository validation by allowing port number.
  • Loading branch information
mattnworb authored Oct 15, 2019
2 parents 9d441d4 + 2f8e561 commit 15780af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class BuildMojo extends AbstractDockerMojo {
/**
* Regex for a valid docker repository name. Used in validateRepository().
*/
private static final String VALID_REPO_REGEX = "^([a-z0-9_.-])+(\\/[a-z0-9_.-]+)*$";
private static final String VALID_REPO_REGEX = "^([a-z0-9_.-])+(:[0-9]{1,5})?(\\/[a-z0-9_.-]+)*$";

/**
* Directory containing the the build context. This is typically the directory that contains
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void testSuccess() throws MojoFailureException {
assertTrue("Start and end with dots", BuildMojo.validateRepository(".start.and.end."));
assertTrue("Start and end with hyphens", BuildMojo.validateRepository("-start-and-end-"));
assertTrue("Start and end with underscores", BuildMojo.validateRepository("_start_and_end_"));
assertTrue("May contain port", BuildMojo.validateRepository("example.com:443/okay./.path"));
// Forward slash delimits the repo user from the repo name; strictly speaking,
// you're allowed only one slash, somewhere in the middle.
assertTrue("Multipart", BuildMojo.validateRepository("with/forwardslash"));
Expand All @@ -59,5 +60,8 @@ public void testFailCases() {
assertFalse("Symbols didn't fail", BuildMojo.validateRepository("ddddddDd+dddd"));
assertFalse("Starting slash didn't fail", BuildMojo.validateRepository("/atstart"));
assertFalse("Ending slash didn't fail", BuildMojo.validateRepository("atend/"));
assertFalse("Only port", BuildMojo.validateRepository(":443"));
assertFalse(
"Port exceeding range", BuildMojo.validateRepository("example.com:100000/myproject"));
}
}

0 comments on commit 15780af

Please sign in to comment.