Skip to content

Commit 49f3ea9

Browse files
committed
CLJS-1388: Stacktrace element handling for :output-dir w/o file/line/column
1 parent d946a58 commit 49f3ea9

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

src/main/cljs/cljs/stacktrace.cljc

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,25 @@
5858
[repl-env st err opts] st)
5959

6060
(defn parse-file-line-column [flc]
61-
(let [xs (string/split flc #":")
62-
[pre [line column]]
63-
(reduce
64-
(fn [[pre post] [x i]]
65-
(if (<= i 2)
66-
[pre (conj post x)]
67-
[(conj pre x) post]))
68-
[[] []] (map vector xs (range (count xs) 0 -1)))
69-
file (string/join ":" pre)]
70-
[(cond-> file
71-
(starts-with? file "(") (string/replace "(" ""))
72-
(parse-int
73-
(cond-> line
74-
(ends-with? line ")") (string/replace ")" "")))
75-
(parse-int
76-
(cond-> column
77-
(ends-with? column ")") (string/replace ")" "")))]))
61+
(if-not (re-find #":" flc)
62+
[flc nil nil]
63+
(let [xs (string/split flc #":")
64+
[pre [line column]]
65+
(reduce
66+
(fn [[pre post] [x i]]
67+
(if (<= i 2)
68+
[pre (conj post x)]
69+
[(conj pre x) post]))
70+
[[] []] (map vector xs (range (count xs) 0 -1)))
71+
file (string/join ":" pre)]
72+
[(cond-> file
73+
(starts-with? file "(") (string/replace "(" ""))
74+
(parse-int
75+
(cond-> line
76+
(ends-with? line ")") (string/replace ")" "")))
77+
(parse-int
78+
(cond-> column
79+
(ends-with? column ")") (string/replace ")" "")))])))
7880

7981
(defn parse-file
8082
"Given a browser file url convert it into a relative path that can be used
@@ -215,7 +217,7 @@
215217
[file line column] (parse-file-line-column flc)]
216218
(if (and file function line column)
217219
{:file (parse-file repl-env file opts)
218-
:function function
220+
:function (string/trim function)
219221
:line line
220222
:column column}
221223
(when-not (string/blank? function)
@@ -244,6 +246,14 @@
244246
vec))
245247

246248
(comment
249+
(parse-stacktrace {}
250+
"cljs$core$seq@out/cljs/core.js:3999:17
251+
cljs$core$first@out/cljs/core.js:4018:22
252+
cljs$core$ffirst@out/cljs/core.js:5161:39
253+
global code"
254+
{:ua-product :safari}
255+
{:output-dir "out"})
256+
247257
(parse-stacktrace {:host "localhost" :port 9000}
248258
"cljs$core$seq@http://localhost:9000/out/cljs/core.js:4259:17
249259
cljs$core$first@http://localhost:9000/out/cljs/core.js:4289:22

0 commit comments

Comments
 (0)