-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom prefix #924
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks! (Untested.)
|
||
@Test public void noPrefix() throws Throwable { | ||
rr.noPrefix().startJenkins(); | ||
assertThat(rr.getUrl().getPath(), emptyString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be equalTo("/")
?
@@ -825,7 +859,7 @@ public URL getUrl() throws MalformedURLException { | |||
if (port == 0) { | |||
throw new IllegalStateException("This method must be called after calling #startJenkins."); | |||
} | |||
return new URL(https ? "https" : "http", host, port, "/jenkins/"); | |||
return new URL(https ? "https" : "http", host, port, prefix == null ? "" : prefix + "/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return new URL(https ? "https" : "http", host, port, prefix == null ? "" : prefix + "/"); | |
return new URL(https ? "https" : "http", host, port, prefix == null ? "/" : prefix + "/"); |
var sanitized = Util.fixEmpty(prefix); | ||
if (sanitized == null) { | ||
throw new IllegalStateException("Use noPrefix() to remove the prefix."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To my mind it would be clearer to delete noPrefix
and just let .withPrefix("")
mean to request http://localhost:12345/
which would be consistent with .withPrefix("/xxx")
meaning http://localhost:12345/xxx/
. The root URL is always expected to end with a slash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent treatment.
Fixes #917
Testing done
Submitter checklist