sprockets-urlrewriter 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sprockets-urlrewriter.rb +4 -4
- data/lib/sprockets-urlrewriter/version.rb +1 -1
- data/spec/urlrewriter_spec.rb +15 -4
- metadata +8 -8
@@ -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
|
17
|
-
next url if URI.parse($
|
18
|
-
new_path = rel.join Pathname.new($
|
19
|
-
"
|
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
|
data/spec/urlrewriter_spec.rb
CHANGED
@@ -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 '
|
34
|
+
it 'allows whitespace between : and url' do
|
35
35
|
@css = "body { background-url: url('image.png') }"
|
36
|
-
assert_equal "body { background-url:
|
36
|
+
assert_equal "body { background-url: url(/assets/css/image.png) }", subject
|
37
37
|
end
|
38
38
|
|
39
|
-
it '
|
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:
|
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.
|
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-
|
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: &
|
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: *
|
24
|
+
version_requirements: *70198582990860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
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: *
|
35
|
+
version_requirements: *70198582990440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sprockets
|
38
|
-
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: *
|
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:
|