Skip to content

Commit e3be29f

Browse files
committed
Allow underscores in git download location
Fixes #33
1 parent f375fa1 commit e3be29f

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/main/java/org/spdx/library/model/v2/SpdxConstantsCompatV2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ public class SpdxConstantsCompatV2 {
365365
// Download Location Format
366366
private static final String SUPPORTED_DOWNLOAD_REPOS = "(git|hg|svn|bzr)";
367367
private static final String URL_PATTERN = "([^:/?#]+://)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+){0,100}\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?";
368-
private static final String GIT_PATTERN = "(git\\+git@[a-zA-Z0-9\\.\\-]+:[a-zA-Z0-9/\\\\.@\\-]+)";
368+
private static final String GIT_PATTERN = "(git\\+git@[a-zA-Z0-9\\.\\-]+:[a-zA-Z0-9/\\\\.@\\-_]+)";
369369
private static final String BAZAAR_PATTERN = "(bzr\\+lp:[a-zA-Z0-9\\.\\-]+)";
370370
public static final Pattern DOWNLOAD_LOCATION_PATTERN = Pattern.compile("^(NONE|NOASSERTION|(("+SUPPORTED_DOWNLOAD_REPOS+"\\+)?"+URL_PATTERN+")|"+GIT_PATTERN+"|"+BAZAAR_PATTERN+")$", Pattern.CASE_INSENSITIVE);
371371

src/test/java/org/spdx/library/model/compat/v2/SpdxPackageTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class SpdxPackageTest extends TestCase {
7070
static final String DESCRIPTION2 = "Description 2";
7171
static final String DOWNLOAD_LOCATION1 = "git+git://git.myproject.org/MyProject";
7272
static final String DOWNLOAD_LOCATION2 = "hg+https://hg.myproject.org/MyProject#src/somefile.c";
73+
static final String DOWNLOAD_LOCATION3 = "git+git://git.myproject.org/MyProject_test";
7374
static final String HOMEPAGE1 = "http://home.page.one/one";
7475
static final String HOMEPAGE2 = "http://home.page.two/two2";
7576
static final String ORIGINATOR1 = "Organization: Originator1";
@@ -608,6 +609,9 @@ public void testSetDownloadLocation() throws InvalidSPDXAnalysisException {
608609
assertEquals(DOWNLOAD_LOCATION_S3, pkg.getDownloadLocation().get());
609610
assertEquals(DOWNLOAD_LOCATION_S3, pkg2.getDownloadLocation().get());
610611
assertTrue(pkg.verify().isEmpty());
612+
pkg.setDownloadLocation(DOWNLOAD_LOCATION3);
613+
assertEquals(DOWNLOAD_LOCATION3, pkg.getDownloadLocation().get());
614+
assertTrue(pkg.verify().isEmpty());
611615
}
612616

613617
/**

0 commit comments

Comments
 (0)