FEATURE: 'More' link points to actual request path (#389)

FEATURE: ‘More’ link points to actual request path (#389)

  • ‘More’ link points to the path of the actual request, not the current window location

  • Hide ‘more’ link on non GET requests

  • Add ‘more’ link back in for non-GET requests

  • Removed more_path concept, to be generated in JS

  • Added semicolon in moreUrl…

diff --git a/lib/html/includes.js b/lib/html/includes.js
index 70e9511..d554215 100644
--- a/lib/html/includes.js
+++ b/lib/html/includes.js
@@ -602,7 +602,7 @@ var MiniProfiler = (function () {
 
           window.fetch = function(input,init) {
               var originalFetchRun = __originalFetch(input,init)
-              
+
               originalFetchRun.then(function(response) {
                   try {
                       // look for x-mini-profile-ids
@@ -618,7 +618,7 @@ var MiniProfiler = (function () {
                       console.error(e)
                   }
               })
-              
+
               return originalFetchRun
           }
           window.fetch.__patchedByMiniProfiler = true;
@@ -824,10 +824,11 @@ var MiniProfiler = (function () {
             return options.path + 'results?id=' + id;
         },
 
-        moreUrl: function () {
-          var loc = window.location.href;
-          loc = loc.indexOf("?") > 0 ? loc + "&pp=help" : "?pp=help";
-          return loc;
+        moreUrl: function (requestName) {
+          var requestParts = requestName.split(" ");
+          var linkSrc = requestParts[0] == 'GET' ? requestParts[1] : window.location.href;
+          var linkSuffix = linkSrc.indexOf("?") > 0 ?  "&pp=help" :  "?pp=help";
+          return (linkSrc + linkSuffix);
         },
 
         getClientTimings: function (clientTimings) {
diff --git a/lib/html/includes.tmpl b/lib/html/includes.tmpl
index 80e0a99..3b3ee91 100644
--- a/lib/html/includes.tmpl
+++ b/lib/html/includes.tmpl
@@ -44,7 +44,7 @@
             <tr>
               <td colspan="3">
                 {{if !client_timings}}
-                {{tmpl "#linksTemplate"}}
+                  {{tmpl({timing:root, page:this.data}) "#linksTemplate"}}
                 {{/if}}
                 <a class="profiler-toggle-duration-with-children" title="toggles column with aggregate child durations">show time with children</a>
               </td>
@@ -89,7 +89,7 @@
           </tbody>
           <tfoot>
             <td colspan="3">
-              {{tmpl "#linksTemplate"}}
+              {{tmpl({timing:root, page:this.data}) "#linksTemplate"}}
             </td>
           </tfoot>
         </table>
@@ -127,8 +127,8 @@
 </script>
 
 <script id="linksTemplate" type="text/x-jquery-tmpl">
-  <a href="${MiniProfiler.shareUrl(id)}" class="profiler-share-profiler-results" target="_blank">share</a>
-  <a href="${MiniProfiler.moreUrl()}" class="profiler-more-actions">more</a>
+  <a href="${MiniProfiler.shareUrl(page.id)}" class="profiler-share-profiler-results" target="_blank">share</a>
+  <a href="${MiniProfiler.moreUrl(timing.name)}" class="profiler-more-actions">more</a>
   {{if custom_link}}
   <a href="${custom_link}" class="profiler-custom-link" target="_blank">${custom_link_name}</a>
   {{/if}}
@@ -218,7 +218,7 @@
 
   <tr class="profiler-gap-info{{if g.duration < 4}} profiler-trivial-gaps{{/if}}">
     <td class="profiler-info">
-      ${g.duration} <span class="profiler-unit">ms</span>  
+      ${g.duration} <span class="profiler-unit">ms</span>
     </td>
     <td class="query">
       <div>${g.topReason.name} &mdash; ${g.topReason.duration.toFixed(2)} <span class="profiler-unit">ms</span></div>

GitHub sha: cc2620ba

1 Like