roda 3.107.0 → 3.108.0
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/roda/plugins/_base64.rb +2 -2
- data/lib/roda/plugins/_optimized_matching.rb +1 -0
- data/lib/roda/plugins/all_verbs.rb +2 -2
- data/lib/roda/plugins/assets.rb +4 -4
- data/lib/roda/plugins/bearer_token.rb +2 -2
- data/lib/roda/plugins/break.rb +9 -1
- data/lib/roda/plugins/caching.rb +12 -12
- data/lib/roda/plugins/common_logger.rb +4 -4
- data/lib/roda/plugins/cookie_flags.rb +2 -2
- data/lib/roda/plugins/each_part.rb +4 -4
- data/lib/roda/plugins/error_email.rb +2 -2
- data/lib/roda/plugins/exception_page.rb +2 -2
- data/lib/roda/plugins/h.rb +4 -4
- data/lib/roda/plugins/hash_branches.rb +8 -4
- data/lib/roda/plugins/hash_paths.rb +4 -2
- data/lib/roda/plugins/hash_public.rb +2 -2
- data/lib/roda/plugins/hmac_paths.rb +27 -29
- data/lib/roda/plugins/host_routing.rb +29 -4
- data/lib/roda/plugins/invalid_request_body.rb +2 -0
- data/lib/roda/plugins/json_parser.rb +20 -2
- data/lib/roda/plugins/mail_processor.rb +2 -2
- data/lib/roda/plugins/mailer.rb +4 -4
- data/lib/roda/plugins/optimized_segment_matchers.rb +13 -6
- data/lib/roda/plugins/optimized_string_matchers.rb +6 -3
- data/lib/roda/plugins/params_capturing.rb +16 -7
- data/lib/roda/plugins/params_capturing_restore.rb +72 -0
- data/lib/roda/plugins/part.rb +4 -4
- data/lib/roda/plugins/pass.rb +4 -1
- data/lib/roda/plugins/path.rb +6 -6
- data/lib/roda/plugins/path_matchers.rb +5 -1
- data/lib/roda/plugins/public.rb +4 -4
- data/lib/roda/plugins/render.rb +24 -12
- data/lib/roda/plugins/render_coverage.rb +7 -6
- data/lib/roda/plugins/render_each.rb +2 -2
- data/lib/roda/plugins/route_csrf.rb +35 -3
- data/lib/roda/plugins/run_append_slash.rb +8 -4
- data/lib/roda/plugins/sec_fetch_site_csrf.rb +5 -2
- data/lib/roda/plugins/sessions.rb +2 -2
- data/lib/roda/plugins/shape_friendly.rb +4 -4
- data/lib/roda/plugins/static.rb +3 -0
- data/lib/roda/plugins/type_routing.rb +1 -1
- data/lib/roda/plugins/url_escape.rb +2 -2
- data/lib/roda/plugins/view_options.rb +3 -5
- data/lib/roda/plugins.rb +4 -4
- data/lib/roda/request.rb +25 -9
- data/lib/roda/version.rb +1 -1
- data/lib/roda.rb +7 -7
- metadata +2 -1
data/lib/roda/request.rb
CHANGED
|
@@ -437,8 +437,15 @@ class Roda
|
|
|
437
437
|
|
|
438
438
|
# Match the given hash if all hash matchers match.
|
|
439
439
|
def _match_hash(hash)
|
|
440
|
+
rp = @remaining_path
|
|
441
|
+
captures_len = @captures.length
|
|
442
|
+
|
|
440
443
|
# Allow calling private methods, as match methods are generally private
|
|
441
|
-
hash.all?{|k,v| send("match_#{k}", v)}
|
|
444
|
+
return true if hash.all?{|k,v| send("match_#{k}", v)}
|
|
445
|
+
|
|
446
|
+
@remaining_path = rp
|
|
447
|
+
@captures.slice!(captures_len, 10000000)
|
|
448
|
+
false
|
|
442
449
|
end
|
|
443
450
|
|
|
444
451
|
# Match integer segment of up to 100 decimal characters, and yield resulting value as an
|
|
@@ -510,6 +517,7 @@ class Roda
|
|
|
510
517
|
rp = @remaining_path
|
|
511
518
|
if rp.getbyte(0) == 47
|
|
512
519
|
if last = rp.index('/', 1)
|
|
520
|
+
return false if last == 1
|
|
513
521
|
@captures << rp[1, last-1]
|
|
514
522
|
@remaining_path = rp[last, rp.length]
|
|
515
523
|
elsif (len = rp.length) > 1
|
|
@@ -568,12 +576,12 @@ class Roda
|
|
|
568
576
|
|
|
569
577
|
if meth
|
|
570
578
|
return unless captures = scope.send(meth, *captures)
|
|
571
|
-
# :
|
|
579
|
+
# simplecov:disable
|
|
572
580
|
# RODA4: Remove elsif block
|
|
573
581
|
elsif defined?(yield)
|
|
574
582
|
RodaPlugins.warn("Passing a block to RodaRequest#consume will be ignored in Roda 4. Update the code to pass a scope method symbol as the second argument.")
|
|
575
583
|
return unless captures = yield(*captures)
|
|
576
|
-
# :
|
|
584
|
+
# simplecov:enable
|
|
577
585
|
end
|
|
578
586
|
|
|
579
587
|
@remaining_path = matchdata.post_match
|
|
@@ -594,13 +602,13 @@ class Roda
|
|
|
594
602
|
if regexp.match?(rp)
|
|
595
603
|
if last = rp.index('/', 1)
|
|
596
604
|
val = rp[1, last-1]
|
|
597
|
-
|
|
605
|
+
new_rp = rp[last, rp.length]
|
|
598
606
|
else
|
|
599
607
|
val = rp[1, rp.length]
|
|
600
|
-
|
|
608
|
+
new_rp = ""
|
|
601
609
|
end
|
|
602
610
|
|
|
603
|
-
if meth
|
|
611
|
+
ret = if meth
|
|
604
612
|
if captures = scope.send(meth, val)
|
|
605
613
|
if captures.is_a?(Array)
|
|
606
614
|
@captures.concat(captures)
|
|
@@ -611,12 +619,16 @@ class Roda
|
|
|
611
619
|
else
|
|
612
620
|
@captures << val
|
|
613
621
|
end
|
|
622
|
+
|
|
623
|
+
@remaining_path = new_rp if ret
|
|
624
|
+
|
|
625
|
+
ret
|
|
614
626
|
end
|
|
615
627
|
end
|
|
616
|
-
# :
|
|
628
|
+
# simplecov:disable
|
|
617
629
|
else
|
|
618
630
|
alias _consume_single_segment consume
|
|
619
|
-
# :
|
|
631
|
+
# simplecov:enable
|
|
620
632
|
end
|
|
621
633
|
|
|
622
634
|
# The default path to use for redirects when a path is not given.
|
|
@@ -627,9 +639,13 @@ class Roda
|
|
|
627
639
|
#
|
|
628
640
|
# If the current request is a GET request, raise an error, as otherwise
|
|
629
641
|
# it is easy to create an infinite redirect.
|
|
642
|
+
#
|
|
643
|
+
# If the path starts +//+, then this redirects to the root path
|
|
644
|
+
# (+/+) instead of using a protocol-relative redirect.
|
|
630
645
|
def default_redirect_path
|
|
631
646
|
raise RodaError, "must provide path argument to redirect for get requests" if is_get?
|
|
632
|
-
path
|
|
647
|
+
path = self.path
|
|
648
|
+
path.start_with?('//') ? '/' : path
|
|
633
649
|
end
|
|
634
650
|
|
|
635
651
|
# The default status to use for redirects if a status is not provided,
|
data/lib/roda/version.rb
CHANGED
data/lib/roda.rb
CHANGED
|
@@ -142,9 +142,9 @@ class Roda
|
|
|
142
142
|
block = if RUBY_VERSION >= '2.7'
|
|
143
143
|
eval('lambda{|*a, **kw| instance_exec(*a, **kw, &b)}', nil, __FILE__, __LINE__) # Keyword arguments fallback
|
|
144
144
|
else
|
|
145
|
-
# :
|
|
145
|
+
# simplecov:disable
|
|
146
146
|
lambda{|*a| instance_exec(*a, &b)} # Keyword arguments fallback
|
|
147
|
-
# :
|
|
147
|
+
# simplecov:enable
|
|
148
148
|
end
|
|
149
149
|
else
|
|
150
150
|
arity_meth = meth
|
|
@@ -226,7 +226,7 @@ class Roda
|
|
|
226
226
|
plugin :direct_call
|
|
227
227
|
end
|
|
228
228
|
|
|
229
|
-
if RUBY_VERSION > "2.4" && ([:on, :is, :_verb, :_match_class_String, :_match_class_Integer, :_match_string, :_match_regexp, :empty_path?, :if_match, :match, :_match_class]).all?{|m| self::RodaRequest.instance_method(m).owner == RequestMethods}
|
|
229
|
+
if RUBY_VERSION > "2.4" && ([:on, :is, :_verb, :_match_class_String, :_match_class_Integer, :_match_string, :_match_regexp, :empty_path?, :if_match, :match, :_match_class, :always]).all?{|m| self::RodaRequest.instance_method(m).owner == RequestMethods}
|
|
230
230
|
plugin :_optimized_matching
|
|
231
231
|
end
|
|
232
232
|
end
|
|
@@ -312,9 +312,9 @@ class Roda
|
|
|
312
312
|
plugin.configure(self, *args, &block) if plugin.respond_to?(:configure)
|
|
313
313
|
@app = nil
|
|
314
314
|
end
|
|
315
|
-
# :
|
|
315
|
+
# simplecov:disable
|
|
316
316
|
ruby2_keywords(:plugin) if respond_to?(:ruby2_keywords, true)
|
|
317
|
-
# :
|
|
317
|
+
# simplecov:enable
|
|
318
318
|
|
|
319
319
|
# Setup routing tree for the current Roda application, and build the
|
|
320
320
|
# underlying rack application using the stored middleware. Requires
|
|
@@ -350,9 +350,9 @@ class Roda
|
|
|
350
350
|
@middleware << [args, block].freeze
|
|
351
351
|
@app = nil
|
|
352
352
|
end
|
|
353
|
-
# :
|
|
353
|
+
# simplecov:disable
|
|
354
354
|
ruby2_keywords(:use) if respond_to?(:ruby2_keywords, true)
|
|
355
|
-
# :
|
|
355
|
+
# simplecov:enable
|
|
356
356
|
|
|
357
357
|
private
|
|
358
358
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: roda
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.108.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeremy Evans
|
|
@@ -259,6 +259,7 @@ files:
|
|
|
259
259
|
- lib/roda/plugins/padrino_render.rb
|
|
260
260
|
- lib/roda/plugins/param_matchers.rb
|
|
261
261
|
- lib/roda/plugins/params_capturing.rb
|
|
262
|
+
- lib/roda/plugins/params_capturing_restore.rb
|
|
262
263
|
- lib/roda/plugins/part.rb
|
|
263
264
|
- lib/roda/plugins/partials.rb
|
|
264
265
|
- lib/roda/plugins/pass.rb
|