Skip to content

Commit

Permalink
CLJS-608: Stop re-seq after reaching end of string
Browse files Browse the repository at this point in the history
  • Loading branch information
thieman authored and swannodette committed Oct 17, 2013
1 parent 6906a56 commit e483c4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cljs/cljs/core.cljs
Expand Up @@ -6564,7 +6564,7 @@ reduces them without incurring seq initialization"
match-idx (.search s re)
match-str (if (coll? match-data) (first match-data) match-data)
post-match (subs s (+ match-idx (count match-str)))]
(when match-data (lazy-seq (cons match-data (re-seq re post-match))))))
(when match-data (lazy-seq (cons match-data (when (seq post-match) (re-seq re post-match)))))))

(defn re-pattern
"Returns an instance of RegExp which has compiled the provided string."
Expand Down
3 changes: 3 additions & 0 deletions test/cljs/cljs/core_test.cljs
Expand Up @@ -1960,5 +1960,8 @@
;; CLJS-600
(assert (= "foobar" (apply str (concat "foo" "bar"))))

;; CLJS-608
(assert (= '("") (re-seq #"\s*" "")))

:ok
)

0 comments on commit e483c4a

Please sign in to comment.