lib/css_parser.rb in css_parser-1.1.9 vs lib/css_parser.rb in css_parser-1.2.1

- old
+ new

@@ -1,15 +1,16 @@ +require 'addressable/uri' require 'uri' require 'net/https' require 'open-uri' require 'digest/md5' require 'zlib' require 'stringio' require 'iconv' module CssParser - VERSION = '1.1.9' + VERSION = '1.2.0' # Merge multiple CSS RuleSets by cascading according to the CSS 2.1 cascading rules # (http://www.w3.org/TR/REC-CSS2/cascade.html#cascading-order). # # Takes one or more RuleSet objects. @@ -137,24 +138,22 @@ # ==== Example # CssParser.convert_uris("body { background: url('../style/yellow.png?abc=123') };", # "http://example.org/style/basic.css").inspect # => "body { background: url('http://example.org/style/yellow.png?abc=123') };" def self.convert_uris(css, base_uri) - out = '' - base_uri = URI.parse(base_uri) unless base_uri.kind_of?(URI) + base_uri = Addressable::URI.parse(base_uri) unless base_uri.kind_of?(Addressable::URI) - out = css.gsub(URI_RX) do |s| + css.gsub(URI_RX) do uri = $1.to_s uri.gsub!(/["']+/, '') # Don't process URLs that are already absolute unless uri =~ /^[a-z]+\:\/\//i begin - uri = base_uri.merge(uri) + uri = base_uri + uri rescue; end end - "url('" + uri.to_s + "')" + "url('#{uri.to_s}')" end - out end end require File.dirname(__FILE__) + '/css_parser/rule_set' require File.dirname(__FILE__) + '/css_parser/regexps'