webrick-route_servlet 1.2.8 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/webrick/route_servlet.rb +16 -1
- data/lib/webrick/route_servlet/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28c27202030d498528554f283d477a4bb1113b2a
|
4
|
+
data.tar.gz: 2113772a490ba1735b1fc206da9b47c43240745b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7c1f897aef431f4d452671a14ccc0c3af2c72a1468c4a9d78b758b81e116d7f6646bccd833204ec426d0c95344ec3ff414e00957d86cfb1aae317a6eb86a810
|
7
|
+
data.tar.gz: 91f0b18a85e00d1a3bee469d7030c7ca6d7d0b2281b062b3a2a510f964b72171c6ac65c399d43aae73b701cf7d89de2ae37a8c36bf48cecbbaa162f64d730f40
|
@@ -148,13 +148,17 @@ module WEBrick
|
|
148
148
|
unless Regexp===re
|
149
149
|
# normalize slash
|
150
150
|
re = re.to_s.gsub(%r#/{2,}#, "/")
|
151
|
+
|
151
152
|
# escape
|
152
153
|
re = re.gsub(/([\.\-?*+\\^$])/, '\\\\\1')
|
154
|
+
|
153
155
|
# start end regexp
|
154
156
|
re = re.sub(%r#^/?#, "^/").sub(%r#/?$#, '/?$')
|
157
|
+
|
155
158
|
# normalize parentheses
|
156
159
|
re = re.gsub(")", ")?")
|
157
|
-
|
160
|
+
|
161
|
+
# constrain named capture ':'
|
158
162
|
constraints = request_options[:constraints] || request_options
|
159
163
|
keys = re.scan(%r#:([^/()\.]+)#).map(&:first).sort{|a,b| b.length <=> a.length}
|
160
164
|
keys.each do |key|
|
@@ -164,6 +168,17 @@ module WEBrick
|
|
164
168
|
end
|
165
169
|
re = re.gsub(":#{key}", value_re.to_s)
|
166
170
|
end
|
171
|
+
|
172
|
+
# constrain named capture '*'
|
173
|
+
keys = re.scan(%r#\\\*([^/()\.]+)#).map(&:first).sort{|a,b| b.length <=> a.length}
|
174
|
+
keys.each do |key|
|
175
|
+
value_re = Regexp.new("(?<#{key}>.+?)")
|
176
|
+
if constraints.respond_to?(:[]) && Regexp===constraints[key.to_sym]
|
177
|
+
value_re = /(?<#{key}>#{constraints[key.to_sym]})/
|
178
|
+
end
|
179
|
+
re = re.gsub("\\*#{key}", value_re.to_s)
|
180
|
+
end
|
181
|
+
|
167
182
|
re = Regexp.new(re)
|
168
183
|
end
|
169
184
|
re
|