Skip to content

Commit c63270b

Browse files
committed
Fix an issue where multiline regex strings were getting clobbered.
1 parent 72a7095 commit c63270b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/rewrite_clj/parser/string.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
[rewrite-clj.node :as node]
55
[clojure.tools.reader
66
[edn :as edn]
7-
[reader-types :as r]]))
7+
[reader-types :as r]]
8+
[clojure.string :as string]))
89

910
(defn- flush-into
1011
"Flush buffer and add string to the given vector."
@@ -38,5 +39,5 @@
3839

3940
(defn parse-regex
4041
[reader]
41-
(let [[h & _] (read-string-data reader)]
42-
(node/token-node (re-pattern h))))
42+
(let [h (read-string-data reader)]
43+
(node/token-node (re-pattern (string/join "\n" h)))))

test/rewrite_clj/parser_test.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@
118118
?s ?p
119119
"#\"regex\"" "regex"
120120
"#\"regex\\.\"" "regex\\."
121-
"#\"[reg|k].x\"" "[reg|k].x")
121+
"#\"[reg|k].x\"" "[reg|k].x"
122+
"#\"a\\nb\"" "a\\nb"
123+
"#\"a\nb\"" "a\nb")
122124

123125
(tabular
124126
(fact "about parsing strings"

0 commit comments

Comments
 (0)