Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static Collection<ProfilerRequestInterface> createRequestsFromIndexHtml(@
if(tokenLink != null) {
String href = tokenLink.getAttributeValue("href");
if(StringUtils.isNotBlank(href)) {
profilerUrl = StringUtils.stripEnd(baseUrl, "/") + href;
profilerUrl = getProfilerAbsoluteUrl(baseUrl, href);
}
}

Expand All @@ -153,6 +153,11 @@ public static Collection<ProfilerRequestInterface> createRequestsFromIndexHtml(@
return requests;
}

@NotNull
private static String getProfilerAbsoluteUrl(@NotNull String baseUrl, @NotNull String href) {
return StringUtils.stripEnd(baseUrl, "/") + href.substring(href.indexOf("/_profiler/"));
}

@NotNull
public static Collection<ProfilerRequestInterface> collectHttpDataForRequest(@NotNull Project project, @NotNull Collection<ProfilerRequestInterface> requests) {
Collection<Callable<ProfilerRequestInterface>> callable = requests.stream().map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ public void testCreateRequestsFromIndexHtml() {
assertEquals(404, request.getStatusCode());
}

/**
* @see ProfilerUtil#createRequestsFromIndexHtml
*/
public void testCreateRequestsFromIndexHtmlRemovesProfilerRoutePrefixFromTokenLinks() {
PsiFile psiFile = myFixture.configureByFile("profiler-index-with-route-prefix.html");
Collection<ProfilerRequestInterface> requests = ProfilerUtil.createRequestsFromIndexHtml(getProject(), psiFile.getText(), "http://127.0.0.1:8000/prefix/");

ProfilerRequestInterface request = requests.iterator().next();

assertEquals("a9eaab", request.getHash());
assertEquals("GET", request.getMethod());
assertEquals("http://127.0.0.1:8000/prefix/_profiler/search/results?ip=&amp;limit=10", request.getUrl());
assertEquals("http://127.0.0.1:8000/prefix/_profiler/a9eaab", request.getProfilerUrl());
assertEquals(404, request.getStatusCode());
}

/**
* @see ProfilerUtil#getRequestAttributes
*/
Expand Down
Loading