Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Generate urls with bang characters #36

Merged
merged 2 commits into from

2 participants

@pixeltrix

The vendored Regin doesn't parse bang characters and so fails to generate urls with them in. This pull request adds a failing test and updates the vendored Regin with the changes from the fix to Regin.

@josh josh merged commit de66a21 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 11, 2012
  1. @pixeltrix
  2. @pixeltrix

    Update vendored Regin

    pixeltrix authored
This page is out of date. Refresh to see the latest.
View
298 lib/rack/mount/vendor/regin/regin/parser.rb
@@ -30,94 +30,96 @@ def initialize
##### State transition tables begin ###
racc_action_table = [
- 43, 44, 46, 48, 4, 52, 17, 9, 10, 11,
- 13, 30, 28, 19, 20, 21, 4, 6, 7, 9,
- 10, 11, 13, 55, 45, 47, 49, 50, 4, 6,
- 7, 9, 10, 11, 13, 80, 56, 47, 49, 50,
- 4, 6, 7, 9, 10, 11, 13, 83, 47, 49,
- 50, 81, 4, 6, 7, 9, 10, 11, 13, 74,
- 47, 49, 50, 31, 4, 6, 7, 9, 10, 11,
- 13, 47, 49, 50, 32, 85, 4, 6, 7, 9,
- 10, 11, 13, 47, 49, 50, 86, 33, 4, 6,
- 7, 9, 10, 11, 13, 47, 49, 50, 88, 89,
- 4, 6, 7, 9, 10, 11, 13, 47, 49, 50,
- 27, 91, 4, 6, 7, 9, 10, 11, 13, 22,
- 34, 23, 36, 41, 25, 6, 7, 58, 60, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 57, 59,
- 61, 22, 22, 38, 22, 72, 25, 39, 95, 39,
- 47, 49, 50 ]
+ 53, 54, 56, 23, 45, 47, 49, 4, 26, 80,
+ 9, 10, 11, 13, 15, 57, 48, 50, 51, 4,
+ 6, 7, 9, 10, 11, 13, 15, 46, 48, 50,
+ 51, 4, 6, 7, 9, 10, 11, 13, 15, 84,
+ 48, 50, 51, 4, 6, 7, 9, 10, 11, 13,
+ 15, 75, 48, 50, 51, 4, 6, 7, 9, 10,
+ 11, 13, 15, 48, 50, 51, 29, 4, 6, 7,
+ 9, 10, 11, 13, 15, 82, 30, 32, 33, 4,
+ 6, 7, 9, 10, 11, 13, 15, 48, 50, 51,
+ 86, 4, 6, 7, 9, 10, 11, 13, 15, 48,
+ 50, 51, 34, 4, 6, 7, 9, 10, 11, 13,
+ 15, 48, 50, 51, 88, 4, 6, 7, 9, 10,
+ 11, 13, 15, 48, 50, 51, 89, 28, 6, 7,
+ 59, 61, 63, 64, 65, 66, 67, 68, 69, 70,
+ 71, 58, 60, 62, 18, 91, 92, 35, 37, 42,
+ 20, 21, 22, 23, 96, 24, 23, 39, 26, 23,
+ 73, 40, nil, nil, 40 ]
racc_action_check = [
- 28, 28, 28, 28, 13, 29, 3, 13, 13, 13,
- 13, 14, 13, 3, 3, 3, 31, 13, 13, 31,
- 31, 31, 31, 35, 28, 28, 28, 28, 0, 31,
- 31, 0, 0, 0, 0, 51, 35, 84, 84, 84,
- 80, 0, 0, 80, 80, 80, 80, 73, 73, 73,
- 73, 71, 1, 80, 80, 1, 1, 1, 1, 42,
- 42, 42, 42, 15, 48, 1, 1, 48, 48, 48,
- 48, 83, 83, 83, 19, 75, 46, 48, 48, 46,
- 46, 46, 46, 87, 87, 87, 76, 20, 30, 46,
- 46, 30, 30, 30, 30, 77, 77, 77, 78, 79,
- 43, 30, 30, 43, 43, 43, 43, 74, 74, 74,
- 12, 81, 44, 43, 43, 44, 44, 44, 44, 4,
- 21, 4, 22, 27, 4, 44, 44, 36, 36, 36,
- 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
- 36, 23, 24, 24, 37, 37, 23, 24, 90, 37,
- 45, 45, 45 ]
+ 30, 31, 36, 24, 30, 30, 30, 47, 24, 52,
+ 47, 47, 47, 47, 47, 36, 85, 85, 85, 0,
+ 47, 47, 0, 0, 0, 0, 0, 30, 30, 30,
+ 30, 29, 0, 0, 29, 29, 29, 29, 29, 74,
+ 74, 74, 74, 80, 29, 29, 80, 80, 80, 80,
+ 80, 44, 44, 44, 44, 53, 80, 80, 53, 53,
+ 53, 53, 53, 84, 84, 84, 14, 15, 53, 53,
+ 15, 15, 15, 15, 15, 72, 15, 16, 20, 49,
+ 15, 15, 49, 49, 49, 49, 49, 87, 87, 87,
+ 76, 1, 49, 49, 1, 1, 1, 1, 1, 77,
+ 77, 77, 21, 32, 1, 1, 32, 32, 32, 32,
+ 32, 46, 46, 46, 78, 45, 32, 32, 45, 45,
+ 45, 45, 45, 75, 75, 75, 79, 12, 45, 45,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 3, 81, 82, 22, 23, 28,
+ 3, 3, 3, 4, 90, 4, 25, 25, 4, 38,
+ 38, 25, nil, nil, 38 ]
racc_action_pointer = [
- 25, 49, nil, -5, 116, nil, nil, nil, nil, nil,
- nil, nil, 110, 1, 9, 61, nil, nil, nil, 63,
- 76, 112, 108, 138, 139, nil, nil, 123, -12, -5,
- 85, 13, nil, nil, nil, 15, 105, 141, nil, nil,
- nil, nil, 23, 97, 109, 113, 73, nil, 61, nil,
- nil, 21, nil, nil, nil, nil, nil, nil, nil, nil,
+ 16, 88, nil, 132, 150, nil, nil, nil, nil, nil,
+ nil, nil, 127, nil, 64, 64, 75, nil, nil, nil,
+ 66, 90, 139, 134, 0, 153, nil, nil, 149, 28,
+ -9, -10, 100, nil, nil, nil, -6, 108, 156, nil,
+ nil, nil, nil, nil, 15, 112, 74, 4, nil, 76,
+ nil, nil, -5, 52, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 37, nil, 11, 70, 65, 76, 58, 88, 89,
- 37, 107, nil, 34, 0, nil, nil, 46, nil, nil,
- 138, nil, nil, nil, nil, nil ]
+ nil, nil, 61, nil, 3, 86, 79, 62, 103, 115,
+ 40, 134, 142, nil, 26, -21, nil, 50, nil, nil,
+ 143, nil, nil, nil, nil, nil, nil ]
racc_action_default = [
- -59, -5, -7, -9, -59, -10, -23, -24, -15, -13,
- -14, -16, -59, -59, -1, -2, -6, -27, -8, -25,
- -26, -59, -59, -59, -59, -36, -35, -59, -59, -59,
- -59, -59, -28, -29, -32, -59, -59, -59, -11, -34,
- -33, 96, -59, -59, -59, -59, -59, -56, -59, -57,
- -58, -59, -17, -3, -4, -31, -30, -49, -38, -50,
- -39, -51, -40, -41, -42, -43, -44, -45, -46, -47,
- -48, -59, -12, -59, -59, -59, -59, -59, -59, -59,
- -59, -59, -55, -59, -59, -18, -19, -59, -21, -22,
- -59, -37, -54, -53, -52, -20 ]
+ -60, -5, -7, -9, -60, -10, -24, -25, -15, -13,
+ -14, -16, -60, -17, -1, -60, -2, -6, -28, -8,
+ -26, -27, -60, -60, -60, -60, -37, -36, -60, -60,
+ -60, -60, -60, -29, -30, -33, -60, -60, -60, -11,
+ -35, -34, 97, -3, -60, -60, -60, -60, -57, -60,
+ -58, -59, -60, -60, -18, -4, -32, -31, -50, -39,
+ -51, -40, -52, -41, -42, -43, -44, -45, -46, -47,
+ -48, -49, -60, -12, -60, -60, -60, -60, -60, -60,
+ -60, -60, -60, -56, -60, -60, -19, -60, -22, -23,
+ -60, -20, -38, -55, -54, -53, -21 ]
racc_goto_table = [
- 12, 24, 40, 35, 42, 53, 54, 16, 18, 71,
- 51, nil, nil, 29, nil, 40, nil, nil, 73, nil,
- 37, 77, nil, nil, nil, nil, nil, nil, nil, nil,
+ 12, 41, 25, 43, 36, 17, 55, 44, 19, 72,
+ 52, nil, nil, nil, 41, 31, nil, nil, nil, nil,
+ nil, 74, 38, 77, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 75, 76, nil, 78, nil, 79, 82,
- 84, nil, nil, 87, nil, nil, nil, nil, nil, 92,
- 93, nil, nil, 94, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, 76, nil, 78, nil, 79,
+ nil, 83, 85, 81, 87, nil, nil, nil, nil, nil,
+ nil, 93, 94, nil, 95, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
90 ]
racc_goto_check = [
- 1, 9, 13, 12, 15, 3, 3, 5, 7, 14,
- 11, nil, nil, 1, nil, 13, nil, nil, 15, nil,
- 9, 15, nil, nil, nil, nil, nil, nil, nil, nil,
+ 1, 13, 9, 3, 12, 5, 3, 15, 7, 14,
+ 11, nil, nil, nil, 13, 1, nil, nil, nil, nil,
+ nil, 15, 9, 15, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 1, 1, nil, 1, nil, 1, 15,
- 15, nil, nil, 15, nil, nil, nil, nil, nil, 15,
- 15, nil, nil, 15, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, 1, nil, 1, nil, 1,
+ nil, 15, 15, 1, 15, nil, nil, nil, nil, nil,
+ nil, 15, 15, nil, 15, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
1 ]
racc_goto_pointer = [
- nil, 0, nil, -25, nil, 6, nil, 5, nil, -3,
- nil, -18, -18, -22, -27, -24 ]
+ nil, 0, nil, -26, nil, 4, nil, 5, nil, -2,
+ nil, -20, -18, -24, -28, -23 ]
racc_goto_default = [
- nil, nil, 14, 15, 1, 2, 3, nil, 5, nil,
- 8, nil, nil, 26, nil, nil ]
+ nil, nil, 14, 16, 1, 2, 3, nil, 5, nil,
+ 8, nil, nil, 27, nil, nil ]
racc_reduce_table = [
0, 0, :racc_error,
@@ -137,27 +139,28 @@ def initialize
1, 46, :_reduce_14,
1, 46, :_reduce_15,
1, 46, :_reduce_16,
- 3, 48, :_reduce_17,
- 5, 48, :_reduce_18,
+ 1, 46, :_reduce_17,
+ 3, 48, :_reduce_18,
5, 48, :_reduce_19,
- 6, 48, :_reduce_20,
- 5, 48, :_reduce_21,
+ 5, 48, :_reduce_20,
+ 6, 48, :_reduce_21,
5, 48, :_reduce_22,
+ 5, 48, :_reduce_23,
1, 50, :_reduce_none,
1, 50, :_reduce_none,
1, 47, :_reduce_none,
1, 47, :_reduce_none,
1, 47, :_reduce_none,
- 2, 47, :_reduce_28,
2, 47, :_reduce_29,
- 3, 47, :_reduce_30,
- 2, 52, :_reduce_31,
+ 2, 47, :_reduce_30,
+ 3, 47, :_reduce_31,
+ 2, 52, :_reduce_32,
1, 52, :_reduce_none,
- 2, 49, :_reduce_33,
2, 49, :_reduce_34,
+ 2, 49, :_reduce_35,
1, 49, :_reduce_none,
1, 49, :_reduce_none,
- 5, 53, :_reduce_37,
+ 5, 53, :_reduce_38,
1, 54, :_reduce_none,
1, 54, :_reduce_none,
1, 54, :_reduce_none,
@@ -172,17 +175,17 @@ def initialize
1, 54, :_reduce_none,
1, 54, :_reduce_none,
1, 54, :_reduce_none,
- 4, 51, :_reduce_52,
4, 51, :_reduce_53,
4, 51, :_reduce_54,
- 3, 51, :_reduce_55,
- 1, 55, :_reduce_56,
+ 4, 51, :_reduce_55,
+ 3, 51, :_reduce_56,
1, 55, :_reduce_57,
- 1, 55, :_reduce_58 ]
+ 1, 55, :_reduce_58,
+ 1, 55, :_reduce_59 ]
-racc_reduce_n = 59
+racc_reduce_n = 60
-racc_shift_n = 96
+racc_shift_n = 97
racc_token_table = {
false => 0,
@@ -194,11 +197,11 @@ def initialize
:CCLASS => 6,
:DOT => 7,
:CHAR => 8,
- :LPAREN => 9,
- :RPAREN => 10,
- :QMARK => 11,
- :EQUAL => 12,
- :BANG => 13,
+ :BANG => 9,
+ :LPAREN => 10,
+ :RPAREN => 11,
+ :QMARK => 12,
+ :EQUAL => 13,
:COLON => 14,
:NAME => 15,
:L_ANCHOR => 16,
@@ -256,11 +259,11 @@ def initialize
"CCLASS",
"DOT",
"CHAR",
+ "BANG",
"LPAREN",
"RPAREN",
"QMARK",
"EQUAL",
- "BANG",
"COLON",
"NAME",
"L_ANCHOR",
@@ -311,39 +314,39 @@ def initialize
# reduce 0 omitted
def _reduce_1(val, _values, result)
- result = Expression.new(val[0])
+ result = Expression.new(val[0])
result
end
# reduce 2 omitted
def _reduce_3(val, _values, result)
- result = val[0] + [val[2]]
+ result = val[0] + [val[2]]
result
end
def _reduce_4(val, _values, result)
- result = Alternation.new(val[0], val[2])
+ result = Alternation.new(val[0], val[2])
result
end
def _reduce_5(val, _values, result)
- result = Expression.new(val[0])
+ result = Expression.new(val[0])
result
end
def _reduce_6(val, _values, result)
- result = val[0] + [val[1]]
+ result = val[0] + [val[1]]
result
end
def _reduce_7(val, _values, result)
- result = [val[0]]
+ result = [val[0]]
result
end
def _reduce_8(val, _values, result)
- result = val[0].dup(:quantifier => val[1])
+ result = val[0].dup(:quantifier => val[1])
result
end
@@ -352,74 +355,77 @@ def _reduce_8(val, _values, result)
# reduce 10 omitted
def _reduce_11(val, _values, result)
- result = CharacterClass.new(val[1])
+ result = CharacterClass.new(val[1])
result
end
def _reduce_12(val, _values, result)
- result = CharacterClass.new(val[2], :negate => true)
+ result = CharacterClass.new(val[2], :negate => true)
result
end
def _reduce_13(val, _values, result)
- result = CharacterClass.new(val[0])
+ result = CharacterClass.new(val[0])
result
end
def _reduce_14(val, _values, result)
- result = CharacterClass.new('.')
+ result = CharacterClass.new('.')
result
end
def _reduce_15(val, _values, result)
- result = Anchor.new(val[0])
+ result = Anchor.new(val[0])
result
end
def _reduce_16(val, _values, result)
- result = Character.new(val[0])
+ result = Character.new(val[0])
result
end
def _reduce_17(val, _values, result)
- result = Group.new(val[1], :index => @capture_index_stack.pop)
-
+ result = Character.new(val[0])
result
end
def _reduce_18(val, _values, result)
- result = Group.new(val[3], :index => @capture_index_stack.pop, :lookahead => :postive)
-
+ result = Group.new(val[1], :index => @capture_index_stack.pop)
+
result
end
def _reduce_19(val, _values, result)
- result = Group.new(val[3], :index => @capture_index_stack.pop, :lookahead => :negative)
-
+ result = Group.new(val[3], :index => @capture_index_stack.pop, :lookahead => :postive)
+
result
end
def _reduce_20(val, _values, result)
+ result = Group.new(val[3], :index => @capture_index_stack.pop, :lookahead => :negative)
+
+ result
+end
+
+def _reduce_21(val, _values, result)
result = Group.new(val[4], val[2].merge(:capture => false))
@options_stack.pop
-
+
result
end
-def _reduce_21(val, _values, result)
+def _reduce_22(val, _values, result)
result = Group.new(val[3], :capture => false);
-
+
result
end
-def _reduce_22(val, _values, result)
+def _reduce_23(val, _values, result)
result = Group.new(val[3], :name => val[2], :index => @capture_index_stack.pop);
-
+
result
end
-# reduce 23 omitted
-
# reduce 24 omitted
# reduce 25 omitted
@@ -428,49 +434,49 @@ def _reduce_22(val, _values, result)
# reduce 27 omitted
-def _reduce_28(val, _values, result)
- result = val.join
- result
-end
+# reduce 28 omitted
def _reduce_29(val, _values, result)
- result = val.join
+ result = val.join
result
end
def _reduce_30(val, _values, result)
- result = val.join
+ result = val.join
result
end
def _reduce_31(val, _values, result)
- result = val.join
+ result = val.join
result
end
-# reduce 32 omitted
-
-def _reduce_33(val, _values, result)
- result = val.join
+def _reduce_32(val, _values, result)
+ result = val.join
result
end
+# reduce 33 omitted
+
def _reduce_34(val, _values, result)
- result = val.join
+ result = val.join
result
end
-# reduce 35 omitted
+def _reduce_35(val, _values, result)
+ result = val.join
+ result
+end
# reduce 36 omitted
-def _reduce_37(val, _values, result)
- result = val.join
+# reduce 37 omitted
+
+def _reduce_38(val, _values, result)
+ result = val.join
result
end
-# reduce 38 omitted
-
# reduce 39 omitted
# reduce 40 omitted
@@ -497,42 +503,44 @@ def _reduce_37(val, _values, result)
# reduce 51 omitted
-def _reduce_52(val, _values, result)
- @options_stack << result = { val[1] => false, val[2] => false, val[3] => false }
-
- result
-end
+# reduce 52 omitted
def _reduce_53(val, _values, result)
- @options_stack << result = { val[0] => true, val[2] => false, val[3] => false }
-
+ @options_stack << result = { val[1] => false, val[2] => false, val[3] => false }
+
result
end
def _reduce_54(val, _values, result)
- @options_stack << result = { val[0] => true, val[1] => true, val[3] => false }
-
+ @options_stack << result = { val[0] => true, val[2] => false, val[3] => false }
+
result
end
def _reduce_55(val, _values, result)
- @options_stack << result = { val[0] => true, val[1] => true, val[2] => true }
-
+ @options_stack << result = { val[0] => true, val[1] => true, val[3] => false }
+
result
end
def _reduce_56(val, _values, result)
- result = :multiline
+ @options_stack << result = { val[0] => true, val[1] => true, val[2] => true }
+
result
end
def _reduce_57(val, _values, result)
- result = :ignorecase
+ result = :multiline
result
end
def _reduce_58(val, _values, result)
- result = :extended
+ result = :ignorecase
+ result
+end
+
+def _reduce_59(val, _values, result)
+ result = :extended
result
end
View
2  test/fixtures/basic_set_map_19.rb
@@ -83,6 +83,8 @@
foo # bar
$/x) }, { :controller => 'extended' })
+ set.add_route(EchoApp, { :path_info => %r{^/!(/(?<action>[a-z]+))?$} }, { :controller => 'bang', :action => 'index' }, :bang)
+
set.add_route(EchoApp, { :path_info => %r{^/uri_escaping/(?<value>.+)$} }, { :controller => 'uri_escaping' })
set.add_route(EchoApp, { :path_info => %r{^/files/(?<files>.*)$} }, { :controller => 'files', :action => 'index' })
View
6 test/test_generation.rb
@@ -35,6 +35,9 @@ def test_url_with_named_route
assert_equal nil, @app.url(@env, :complex_regexp_fail, :only_path => true)
assert_equal '/prefix', @app.url(@env, :prefix, :only_path => true)
+
+ assert_equal '/!', @app.url(@env, :bang, :only_path => true)
+ assert_equal '/!/about', @app.url(@env, :bang, :action => 'about', :only_path => true)
end
def test_url_with_hash
@@ -64,6 +67,9 @@ def test_url_with_hash
assert_equal ['/default/users/show/1', {}], @app.generate(:path_info, {:action => 'show', :id => '1'}, {:controller => 'users'})
assert_equal ['/default/users/show/1', {}], @app.generate(:path_info, {:controller => 'users', :id => '1'}, {:action => 'show'})
+ assert_equal '/!', @app.url(@env, :controller => 'bang', :only_path => true)
+ assert_equal '/!/about', @app.url(@env, :controller => 'bang', :action => 'about', :only_path => true)
+
assert_raise(Rack::Mount::RoutingError) { @app.url(@env, {}) }
end
Something went wrong with that request. Please try again.