Skip to content

Commit f511073

Browse files
committed
Simplifying snippetizer link URL construction
1 parent 2ed7a0d commit f511073

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

src/main/java/org/jenkinsci/plugins/workflow/cps/SnippetizerLink.java

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,12 @@ public final String getDisplayUrl() {
7575

7676
StaplerRequest req = Stapler.getCurrentRequest();
7777
if (req == null) {
78-
return u;
78+
throw new IllegalStateException("Can't get display URL without Stapler context.");
7979
}
8080

8181
Item i = req.findAncestorObject(Item.class);
8282

83-
StringBuilder toAppend = new StringBuilder();
84-
85-
toAppend.append(req.getContextPath());
86-
87-
if (!req.getContextPath().endsWith("/")) {
88-
toAppend.append("/");
89-
}
90-
91-
if (i == null) {
92-
toAppend.append(u);
93-
} else {
94-
toAppend.append(i.getUrl());
95-
96-
if (!i.getUrl().endsWith("/")) {
97-
toAppend.append("/");
98-
}
99-
100-
toAppend.append(u);
101-
}
102-
103-
return toAppend.toString();
83+
return req.getContextPath() + '/' + (i == null ? "" : i.getUrl()) + u;
10484
}
10585

10686
/**

0 commit comments

Comments
 (0)