clojure.string/replace-first returns nil with replacement fn when regex doesn't match

Description

Originally reported by Takahiro Hozumi

With a function as the "replacement" argument, clojure.string/replace-first returns nil if there is no match, instead of returning the original string unchanged.

1 2 3 4 5 6 7 8 user=> (use 'clojure.string) nil user=> (replace-first "abcdef" "ghi" "jkl") "abcdef" user=> (replace-first "abcdef" #"ghi" "jkl") "abcdef" user=> (replace-first "abcdef" #"ghi" (fn [a] "jkl")) nil

Environment

None

Status

Assignee

Stuart Sierra

Reporter

Stuart Sierra

Labels

None

Approval

Vetted

Patch

Code and Test

Fix versions

Priority

Minor