Skip to content

Commit 93348b1

Browse files
authored
Use absolute URLs for Apache HTTP requests in crawler (#2397)
1 parent 9a313a4 commit 93348b1

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/org/labkey/test/WebTestHelper.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,29 @@ public static String makeRelativeUrl(String url)
355355
return StringUtils.stripStart(url, "/");
356356
}
357357

358+
/**
359+
* Append the test server's base URL to the front of a relative URL. Absolute URLs will be returned unchanged.
360+
* @param url Absolute or relative URL
361+
* @return Absolute URL
362+
*/
363+
public static String makeAbsoluteUrl(String url)
364+
{
365+
if (isAbsoluteUrl(url))
366+
{
367+
return url;
368+
}
369+
else
370+
{
371+
StringBuilder sb = new StringBuilder(getBaseURL());
372+
if (!url.startsWith("/"))
373+
{
374+
sb.append("/");
375+
}
376+
sb.append(url);
377+
return sb.toString();
378+
}
379+
}
380+
358381
public static boolean isAbsoluteUrl(String url)
359382
{
360383
return url.startsWith("http://") || url.startsWith("https://");

src/org/labkey/test/util/Crawler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ else if (urlToCheck.isFromForm()) // Forms may 404 with bad input
11901190

11911191
private boolean doesUrlExist(UrlToCheck urlToCheck)
11921192
{
1193-
final String url = stripQueryParams(urlToCheck.getRelativeURL());
1193+
final String url = WebTestHelper.makeAbsoluteUrl(stripQueryParams(urlToCheck.getRelativeURL()));
11941194

11951195
// Check whether 404 was due to a missing action
11961196
HttpContext context = WebTestHelper.getBasicHttpContext();

0 commit comments

Comments
 (0)