File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 2
2
" Library for parsing the Rails routes syntax."
3
3
(:require [clojure.string :as string])
4
4
(:import java.util.Map
5
+ java.util.regex.Matcher
5
6
[java.net URLDecoder URLEncoder]))
6
7
7
8
; ; Regular expression utilties
19
20
(defn re-groups*
20
21
" More consistant re-groups that always returns a vector of groups, even if
21
22
there is only one group."
22
- [matcher]
23
+ [^Matcher matcher]
23
24
(for [i (range (.groupCount matcher))]
24
- (.group matcher (inc i))))
25
+ (.group matcher (int ( inc i) ))))
25
26
26
27
; ; Route matching
27
28
94
95
(let [matcher (re-matcher re src)]
95
96
(if (.lookingAt matcher)
96
97
[(if (fn? action) (action matcher) action)
97
- (.substring src (.end matcher))])))
98
+ (subs src (.end matcher))])))
98
99
(partition 2 clauses)))
99
100
100
101
(defn- lex
123
124
(let [splat #"\* "
124
125
word #":([\p {L}_][\p {L}_0-9-]*)"
125
126
literal #"(:[^\p {L}_*]|[^:*])+"
126
- word-group #(keyword (.group % 1 ))
127
+ word-group #(keyword (.group ^Matcher % 1 ))
127
128
word-regex #(regexs (word-group %) " [^/,;?]+" )]
128
129
(CompiledRoute.
129
130
(re-pattern
130
131
(apply str
131
132
(lex path
132
133
splat " (.*?)"
133
134
word #(str " (" (word-regex %) " )" )
134
- literal #(re-escape (.group %)))))
135
+ literal #(re-escape (.group ^Matcher %)))))
135
136
(remove nil?
136
137
(lex path
137
138
splat :*
You can’t perform that action at this time.
0 commit comments