Handle git urls with trailing .git suffix correctly

This commit is contained in:
René Pfeuffer
2018-09-10 11:03:10 +02:00
parent 50a4133dff
commit 6bc41cee0a
3 changed files with 16 additions and 2 deletions

View File

@@ -24,7 +24,7 @@ public class RepositoryDto extends HalRepresentation {
@JsonInclude(JsonInclude.Include.NON_NULL)
private Instant lastModified;
private String namespace;
@Pattern(regexp = "(?!^\\.\\.$)(?!^\\.$)(?!.*[\\\\\\[\\]])^[A-z0-9\\.][A-z0-9\\.\\-_/]*$")
@Pattern(regexp = "^[A-z0-9\\-_]+$")
private String name;
private boolean archived = false;
@NotEmpty

View File

@@ -28,6 +28,11 @@ class NamespaceAndNameFromPathExtractor {
String name = uri.substring(endOfNamespace + 1, nameIndex);
return of(new NamespaceAndName(namespace, name));
int nameDotIndex = name.indexOf('.');
if (nameDotIndex >= 0) {
return of(new NamespaceAndName(namespace, name.substring(0, nameDotIndex)));
} else {
return of(new NamespaceAndName(namespace, name));
}
}
}