@@ -47,7 +47,7 @@ module LiquidInterpolatable |
||
| 47 | 47 |
# Ref: http://tools.ietf.org/html/rfc3986#page-12 |
| 48 | 48 |
module Filters |
| 49 | 49 |
def uri_escape(string) |
| 50 |
- CGI::escape string |
|
| 50 |
+ CGI.escape(string) rescue string |
|
| 51 | 51 |
end |
| 52 | 52 |
end |
| 53 | 53 |
Liquid::Template.register_filter(LiquidInterpolatable::Filters) |
@@ -11,6 +11,10 @@ describe LiquidInterpolatable::Filters do |
||
| 11 | 11 |
it 'should escape a string for use in URI' do |
| 12 | 12 |
@filter.uri_escape('abc:/?=').should == 'abc%3A%2F%3F%3D'
|
| 13 | 13 |
end |
| 14 |
+ |
|
| 15 |
+ it 'should not raise an error when an operand is nil' do |
|
| 16 |
+ @filter.uri_escape(nil).should be_nil |
|
| 17 |
+ end |
|
| 14 | 18 |
end |
| 15 | 19 |
|
| 16 | 20 |
describe 'validations' do |