Fix source URL creation for SVN

This commit is contained in:
René Pfeuffer
2018-08-23 17:02:55 +02:00
parent ca563dd874
commit 40f963db98

View File

@@ -26,7 +26,7 @@ public abstract class FileObjectMapper extends BaseMapper<FileObject, FileObject
@AfterMapping
void addLinks(FileObject fileObject, @MappingTarget FileObjectDto dto, @Context NamespaceAndName namespaceAndName, @Context String revision) {
String path = fileObject.getPath();
String path = removeFirstSlash(fileObject.getPath());
Links.Builder links = Links.linkingTo()
.self(addPath(resourceLinks.source().sourceWithPath(namespaceAndName.getNamespace(), namespaceAndName.getName(), revision, ""), path));
if (!dto.isDirectory()) {
@@ -40,4 +40,8 @@ public abstract class FileObjectMapper extends BaseMapper<FileObject, FileObject
private String addPath(String sourceWithPath, String path) {
return URI.create(sourceWithPath).resolve(path).toASCIIString();
}
private String removeFirstSlash(String source) {
return source.startsWith("/") ? source.substring(1) : source;
}
}