Permalink
Browse files

* Better url parsing

  • Loading branch information...
1 parent 395041b commit 1bdbe612f8417bad7c9df0652b00e70c80b40937 @smtlaissezfaire committed Jul 16, 2008
Showing with 27 additions and 1 deletion.
  1. +9 −1 lib/css_parser/url.treetop
  2. +18 −0 spec/css_parser/primitives_parser_spec.rb
View
@@ -20,7 +20,15 @@ grammar URL
end
rule path
- "/" string?
+ "/" string? query_string?
+ end
+
+ rule query_string
+ "?" url_key_value_pair (("&" url_key_value_pair)+)?
+ end
+
+ rule url_key_value_pair
+ string "=" string
end
rule protocol
@@ -202,6 +202,24 @@ def parse(string)
parse("http://localhost:65536").should_not be_nil
end
+ it "should allow a query string with a question mark and key value pair" do
+ parse("http://localhost:3000/foo?bar=quxx").should_not be_nil
+ end
+
+ it "should allow a query string with multiple key value pairs" do
+ parse("http://localhost:3000/foo?bar=quxx&foo=bar").should_not be_nil
+ end
+
+ it "should allow a query string with three key value pairs" do
+ parse("http://localhost:3000/foo?bar=quxx&foo=bar&one=two").should_not be_nil
+ end
+
+ it "should allow a query string with multiple key value pairs with numbers as values" do
+ pending 'todo'
+ parse("http://localhost:3000/foo?bar=1&foo=2").should_not be_nil
+ end
+
+
# TODO: See http://www.w3.org/TR/REC-CSS2/syndata.html#values
# TODO: Numbers, integers

0 comments on commit 1bdbe61

Please sign in to comment.