lib/css_parser/parser.rb in css_parser-1.4.9 vs lib/css_parser/parser.rb in css_parser-1.4.10
- old
+ new
@@ -397,11 +397,11 @@
uri.scheme = 'file'
end
opts[:base_uri] = uri if opts[:base_uri].nil?
- src, charset = read_remote_file(uri)
+ src, = read_remote_file(uri) # skip charset
if src
add_block!(src, opts)
end
end
@@ -481,13 +481,12 @@
return nil, nil
end
src = '', charset = nil
+ uri = Addressable::URI.parse(uri.to_s)
begin
- uri = Addressable::URI.parse(uri.to_s)
-
if uri.scheme == 'file'
# local file
fh = open(uri.path, 'rb')
src = fh.read
fh.close
@@ -506,11 +505,11 @@
src = res.body
charset = fh.respond_to?(:charset) ? fh.charset : 'utf-8'
if res.code.to_i >= 400
@redirect_count = nil
- raise RemoteFileError if @options[:io_exceptions]
+ raise RemoteFileError.new(uri.to_s) if @options[:io_exceptions]
return '', nil
elsif res.code.to_i >= 300 and res.code.to_i < 400
if res['Location'] != nil
return read_remote_file Addressable::URI.parse(Addressable::URI.escape(res['Location']))
end
@@ -534,10 +533,10 @@
src = ic.iconv(src)
end
end
rescue
@redirect_count = nil
- raise RemoteFileError if @options[:io_exceptions]
+ raise RemoteFileError.new(uri.to_s)if @options[:io_exceptions]
return nil, nil
end
@redirect_count = nil
return src, charset