Jelajahi Sumber

Use shorten-url for backtraces

Gaël Métais 10 tahun lalu
induk
melakukan
839bfd4756

+ 1 - 0
front/src/css/timeline.css

@@ -173,6 +173,7 @@ input.textFilter {
 }
 .table > div > .index {
   color: #bbb;
+  word-break: normal;
 }
 .table > div > .type {
   white-space: nowrap;

+ 18 - 12
front/src/js/controllers/timelineCtrl.js

@@ -89,19 +89,25 @@ timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams',
         var out = [];
         var splited = str.split(' / ');
         splited.forEach(function(trace) {
-            var result = /^(\S*)\s?\(?(https?:\/\/\S+):(\d+)\)?$/g.exec(trace);
-            if (result && result[2].length > 0) {
-                var filePath = result[2];
-                var chunks = filePath.split('/');
-                var fileName = chunks[chunks.length - 1];
-
-                out.push({
-                    fnName: result[1],
-                    fileName: fileName,
-                    filePath: filePath,
-                    line: result[3]
-                });
+            var fnName = null, fileAndLine;
+
+            var withFnResult = /^([^\s\(]+) \((.+:\d+)\)$/.exec(trace);
+            if (withFnResult === null) {
+                fileAndLine = trace;
+            } else {
+                fnName = withFnResult[1];
+                fileAndLine = withFnResult[2];
             }
+
+            var fileAndLineSplit = /^(.*):(\d+)$/.exec(fileAndLine);
+            var filePath = fileAndLineSplit[1];
+            var line = fileAndLineSplit[2];
+
+            out.push({
+                fnName: fnName,
+                filePath: filePath,
+                line: line
+            });
         });
         return out;
     }

+ 1 - 0
front/src/less/timeline.less

@@ -191,6 +191,7 @@ input.textFilter {
 
 .table > div > .index {
     color: #bbb;
+    word-break: normal;
 }
 
 .table > div > .type {

+ 1 - 1
front/src/views/timeline.html

@@ -130,7 +130,7 @@
                         <div class="table">
                             <div ng-repeat="trace in node.parsedBacktrace track by $index">
                                 <div>{{trace.fnName || '(anonymous)'}}</div>
-                                <div class="trace"><a href="{{trace.filePath}}" title="{{trace.filePath}}" target="_blank">{{trace.fileName || 'HTML'}}</a>:{{trace.line}}</div>
+                                <div class="trace"><url-link url="trace.filePath" max-length="40"></url-link>:{{trace.line}}</div>
                             </div>
                             <div ng-if="node.parsedBacktrace.length == 0 && node.data.type != 'script loaded'">
                                 <div>can't find any backtrace :/</div>