mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Allow an empty or null base URI
This commit is contained in:
parent
3a0c9e6274
commit
a94cd7fd6d
2 changed files with 13 additions and 3 deletions
|
@ -129,10 +129,11 @@ module LiquidInterpolatable
|
|||
# userinfo, host, port, registry, path, opaque, query, and
|
||||
# fragment.
|
||||
def to_uri(uri, base_uri = nil)
|
||||
if base_uri
|
||||
Utils.normalize_uri(base_uri) + Utils.normalize_uri(uri.to_s)
|
||||
else
|
||||
case base_uri
|
||||
when nil, ''
|
||||
Utils.normalize_uri(uri.to_s)
|
||||
else
|
||||
Utils.normalize_uri(base_uri) + Utils.normalize_uri(uri.to_s)
|
||||
end
|
||||
rescue URI::Error
|
||||
nil
|
||||
|
|
|
@ -119,6 +119,15 @@ describe LiquidInterpolatable::Filters do
|
|||
@agent.interpolation_context['s'] = 'foo/index.html'
|
||||
expect(@agent.interpolated['foo']).to eq('/dir/foo/index.html')
|
||||
end
|
||||
|
||||
it 'should normalize a URI value if an empty base URI is given' do
|
||||
@agent.options['foo'] = '{{ u | to_uri: b }}'
|
||||
@agent.interpolation_context['u'] = "\u{3042}"
|
||||
@agent.interpolation_context['b'] = ""
|
||||
expect(@agent.interpolated['foo']).to eq('%E3%81%82')
|
||||
@agent.interpolation_context['b'] = nil
|
||||
expect(@agent.interpolated['foo']).to eq('%E3%81%82')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'uri_expand' do
|
||||
|
|
Loading…
Add table
Reference in a new issue