diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/profiler/utils/ProfilerUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/profiler/utils/ProfilerUtil.java index 1d073964c..d02663853 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/profiler/utils/ProfilerUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/profiler/utils/ProfilerUtil.java @@ -128,7 +128,7 @@ public static Collection createRequestsFromIndexHtml(@ if(tokenLink != null) { String href = tokenLink.getAttributeValue("href"); if(StringUtils.isNotBlank(href)) { - profilerUrl = StringUtils.stripEnd(baseUrl, "/") + href; + profilerUrl = getProfilerAbsoluteUrl(baseUrl, href); } } @@ -153,6 +153,11 @@ public static Collection 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 collectHttpDataForRequest(@NotNull Project project, @NotNull Collection requests) { Collection> callable = requests.stream().map( diff --git a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/profiler/ProfilerUtilTest.java b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/profiler/ProfilerUtilTest.java index 24df2805f..9609606b8 100644 --- a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/profiler/ProfilerUtilTest.java +++ b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/profiler/ProfilerUtilTest.java @@ -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 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=&limit=10", request.getUrl()); + assertEquals("http://127.0.0.1:8000/prefix/_profiler/a9eaab", request.getProfilerUrl()); + assertEquals(404, request.getStatusCode()); + } + /** * @see ProfilerUtil#getRequestAttributes */ diff --git a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/profiler/fixtures/profiler-index-with-route-prefix.html b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/profiler/fixtures/profiler-index-with-route-prefix.html new file mode 100644 index 000000000..81da43b22 --- /dev/null +++ b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/profiler/fixtures/profiler-index-with-route-prefix.html @@ -0,0 +1,445 @@ + + + + + + + Symfony Profiler + + + + + + +
+
+
+

Profile Search

+
+
+
+ +
+
+
+
+ +

10 results found

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StatusIPMethodURLTimeToken
+ 404 + + 127.0.0.1 + + + + + + + + GET + + + + + + + + http://127.0.0.1:8000/prefix/_profiler/search/results?ip=&limit=10 + + + + + + + + 28-Sep-2016 + 19:35:14 + a9eaab
+ 200 + + 127.0.0.1 + + + + + + + + GET + + + + + + + + http://127.0.0.1:8000/prefix/_profiler/search/results?ip=&limit=10 + + + + + + + + 28-Sep-2016 + 19:35:14 + b5e1bd
+ 301 + + 127.0.0.1 + + + + + + + + GET + + + + + + + + http://127.0.0.1:8000/prefix/_profiler + + + + + + + + 28-Sep-2016 + 19:23:35 + 3afd6f
+ 404 + + 127.0.0.1 + + + + + + + + GET + + + + + + + + http://127.0.0.1:8000/ + + + + + + + + 28-Sep-2016 + 19:23:21 + 0fd1e4
+ 200 + + 127.0.0.1 + + + + + + + + GET + + + + + + + + http://127.0.0.1:8000/ + + + + + + + + 28-Sep-2016 + 19:23:21 + ab269a
+ 500 + + 127.0.0.1 + + + + + + + + GET + + + + + + + + http://127.0.0.1:8000/foobar + + + + + + + + 18-Sep-2016 + 10:12:38 + eb5573
+ 200 + + 127.0.0.1 + + + + + + + + GET + + + + + + + + http://127.0.0.1:8000/foobar + + + + + + + + 18-Sep-2016 + 10:12:38 + d3f91a
+ 500 + + 127.0.0.1 + + + + + + + + GET + + + + + + + + http://127.0.0.1:8000/foobar + + + + + + + + 18-Sep-2016 + 09:56:40 + d0d721
+ 200 + + 127.0.0.1 + + + + + + + + GET + + + + + + + + http://127.0.0.1:8000/foobar + + + + + + + + 18-Sep-2016 + 09:56:40 + b64e3a
+ 500 + + 127.0.0.1 + + + + + + + + GET + + + + + + + + http://127.0.0.1:8000/foobar + + + + + + + + 18-Sep-2016 + 09:55:55 + 2ded8a
+ +
+
+ + +
+
+ +