sprockets-urlrewriter 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,10 +13,10 @@ module Sprockets
13
13
  logical_path = context.instance_variable_get(:@logical_path)
14
14
 
15
15
  rel = Pathname.new(logical_path).parent
16
- data.gsub /:\s*url\(['"]?([^\s)]+\.[a-z]+)(\?\d+)?['"]?\)/i do |url|
17
- next url if URI.parse($1).absolute?
18
- new_path = rel.join Pathname.new($1)
19
- ": url(#{new_path}#{$2})"
16
+ data.gsub /(:|\s)url\(['"]?([^\s)]+\.[a-z]+)(\?\d+)?['"]?\)/i do |url|
17
+ next url if URI.parse($2).absolute?
18
+ new_path = rel.join Pathname.new($2)
19
+ "#{$1}url(#{new_path}#{$3})"
20
20
  end
21
21
  end
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module SprocketsUrlRewriter
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -31,15 +31,26 @@ describe 'UrlRewriter' do
31
31
  assert_equal "body { background-url: url(/assets/css/image.png) }", subject
32
32
  end
33
33
 
34
- it 'ignores whitespace between : and url' do
34
+ it 'allows whitespace between : and url' do
35
35
  @css = "body { background-url: url('image.png') }"
36
- assert_equal "body { background-url: url(/assets/css/image.png) }", subject
36
+ assert_equal "body { background-url: url(/assets/css/image.png) }", subject
37
37
  end
38
38
 
39
- it 'ignores newline between : and url' do
39
+ it 'allows newline between colon and url' do
40
40
  @css = "body { background-url:
41
41
  url('image.png') }"
42
- assert_equal "body { background-url: url(/assets/css/image.png) }", subject
42
+ assert_equal "body { background-url:
43
+ url(/assets/css/image.png) }", subject
44
+ end
45
+
46
+ it 'allows nospace between colon and url' do
47
+ @css = "body { background-url:url('image.png') }"
48
+ assert_equal "body { background-url:url(/assets/css/image.png) }", subject
49
+ end
50
+
51
+ it 'allows things between colon and url' do
52
+ @css = "body { background: no-repeat url('image.png') }"
53
+ assert_equal "body { background: no-repeat url(/assets/css/image.png) }", subject
43
54
  end
44
55
  end
45
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-urlrewriter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-15 00:00:00.000000000 Z
12
+ date: 2012-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &70268489188320 !ruby/object:Gem::Requirement
16
+ requirement: &70198582990860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70268489188320
24
+ version_requirements: *70198582990860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70268489187780 !ruby/object:Gem::Requirement
27
+ requirement: &70198582990440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70268489187780
35
+ version_requirements: *70198582990440
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sprockets
38
- requirement: &70268489187280 !ruby/object:Gem::Requirement
38
+ requirement: &70198582990020 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70268489187280
46
+ version_requirements: *70198582990020
47
47
  description: ! ' Replaces all instances of url() in CSS files Sprockets concats, if
48
48
  the url is relative. '
49
49
  email: