mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
Handle git urls with trailing .git suffix correctly
This commit is contained in:
@@ -24,7 +24,7 @@ public class RepositoryDto extends HalRepresentation {
|
|||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
private Instant lastModified;
|
private Instant lastModified;
|
||||||
private String namespace;
|
private String namespace;
|
||||||
@Pattern(regexp = "(?!^\\.\\.$)(?!^\\.$)(?!.*[\\\\\\[\\]])^[A-z0-9\\.][A-z0-9\\.\\-_/]*$")
|
@Pattern(regexp = "^[A-z0-9\\-_]+$")
|
||||||
private String name;
|
private String name;
|
||||||
private boolean archived = false;
|
private boolean archived = false;
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ class NamespaceAndNameFromPathExtractor {
|
|||||||
|
|
||||||
String name = uri.substring(endOfNamespace + 1, nameIndex);
|
String name = uri.substring(endOfNamespace + 1, nameIndex);
|
||||||
|
|
||||||
|
int nameDotIndex = name.indexOf('.');
|
||||||
|
if (nameDotIndex >= 0) {
|
||||||
|
return of(new NamespaceAndName(namespace, name.substring(0, nameDotIndex)));
|
||||||
|
} else {
|
||||||
return of(new NamespaceAndName(namespace, name));
|
return of(new NamespaceAndName(namespace, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,15 @@ public class NamespaceAndNameFromPathExtractorTest {
|
|||||||
).map(this::createCorrectTest);
|
).map(this::createCorrectTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestFactory
|
||||||
|
Stream<DynamicNode> shouldHandleTrailingDotSomethings() {
|
||||||
|
return Stream.of(
|
||||||
|
"/space/repo.git",
|
||||||
|
"/space/repo.and.more",
|
||||||
|
"/space/repo."
|
||||||
|
).map(this::createCorrectTest);
|
||||||
|
}
|
||||||
|
|
||||||
private DynamicTest createCorrectTest(String path) {
|
private DynamicTest createCorrectTest(String path) {
|
||||||
return dynamicTest(
|
return dynamicTest(
|
||||||
"should extract correct namespace and name for path " + path,
|
"should extract correct namespace and name for path " + path,
|
||||||
|
|||||||
Reference in New Issue
Block a user