Skip to content

Commit bc35f8b

Browse files
authored
Merge pull request #1685 from adamwojs/issue_1674
Fixed #1674: duplicated route prefix in profiler urls
2 parents 6ec4b13 + 360a03c commit bc35f8b

File tree

3 files changed

+467
-1
lines changed

3 files changed

+467
-1
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/profiler/utils/ProfilerUtil.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static Collection<ProfilerRequestInterface> createRequestsFromIndexHtml(@
128128
if(tokenLink != null) {
129129
String href = tokenLink.getAttributeValue("href");
130130
if(StringUtils.isNotBlank(href)) {
131-
profilerUrl = StringUtils.stripEnd(baseUrl, "/") + href;
131+
profilerUrl = getProfilerAbsoluteUrl(baseUrl, href);
132132
}
133133
}
134134

@@ -153,6 +153,11 @@ public static Collection<ProfilerRequestInterface> createRequestsFromIndexHtml(@
153153
return requests;
154154
}
155155

156+
@NotNull
157+
private static String getProfilerAbsoluteUrl(@NotNull String baseUrl, @NotNull String href) {
158+
return StringUtils.stripEnd(baseUrl, "/") + href.substring(href.indexOf("/_profiler/"));
159+
}
160+
156161
@NotNull
157162
public static Collection<ProfilerRequestInterface> collectHttpDataForRequest(@NotNull Project project, @NotNull Collection<ProfilerRequestInterface> requests) {
158163
Collection<Callable<ProfilerRequestInterface>> callable = requests.stream().map(

src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/profiler/ProfilerUtilTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ public void testCreateRequestsFromIndexHtml() {
3939
assertEquals(404, request.getStatusCode());
4040
}
4141

42+
/**
43+
* @see ProfilerUtil#createRequestsFromIndexHtml
44+
*/
45+
public void testCreateRequestsFromIndexHtmlRemovesProfilerRoutePrefixFromTokenLinks() {
46+
PsiFile psiFile = myFixture.configureByFile("profiler-index-with-route-prefix.html");
47+
Collection<ProfilerRequestInterface> requests = ProfilerUtil.createRequestsFromIndexHtml(getProject(), psiFile.getText(), "http://127.0.0.1:8000/prefix/");
48+
49+
ProfilerRequestInterface request = requests.iterator().next();
50+
51+
assertEquals("a9eaab", request.getHash());
52+
assertEquals("GET", request.getMethod());
53+
assertEquals("http://127.0.0.1:8000/prefix/_profiler/search/results?ip=&amp;limit=10", request.getUrl());
54+
assertEquals("http://127.0.0.1:8000/prefix/_profiler/a9eaab", request.getProfilerUrl());
55+
assertEquals(404, request.getStatusCode());
56+
}
57+
4258
/**
4359
* @see ProfilerUtil#getRequestAttributes
4460
*/

0 commit comments

Comments
 (0)