Skip to content

Commit 07ca610

Browse files
committed
Fix duplicate slashes in path
1 parent 45103f2 commit 07ca610

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/ServiceStackIDEA/src/main/java/net/servicestack/idea/UpdateServiceStackUtils.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ public static void updateServiceStackReference(PsiFile psiFile) {
6767

6868
String existingPath = builder.getPath();
6969
if(existingPath == null || existingPath.equals("/")) {
70-
builder.setPath("/" + nativeTypesHandler.getRelativeTypesUrl());
70+
builder.setPath(combinePath("", nativeTypesHandler.getRelativeTypesUrl()));
7171
} else {
72-
builder.setPath(existingPath + "/" + nativeTypesHandler.getRelativeTypesUrl());
72+
builder.setPath(combinePath(existingPath, nativeTypesHandler.getRelativeTypesUrl()));
7373
}
7474

7575
Map<String,String> options = new HashMap<String,String>();
@@ -134,6 +134,18 @@ public static void updateServiceStackReference(PsiFile psiFile) {
134134
}
135135
}
136136

137+
public static String combinePath(String path, String segment) {
138+
if (path == null || path.isEmpty()) {
139+
return "/" + segment;
140+
}
141+
142+
if (path.charAt(path.length() - 1) == '/') {
143+
return path + segment;
144+
}
145+
146+
return path + "/" + segment;
147+
}
148+
137149
public static boolean containsOptionsHeader(PsiFile psiJavaFile) {
138150
Document dtoDocument = FileDocumentManager.getInstance().getDocument(psiJavaFile.getVirtualFile());
139151
if(dtoDocument == null) {

0 commit comments

Comments
 (0)