Comparing version 0.0.3 to 0.0.4
@@ -33,3 +33,3 @@ | ||
if (!item.match(/^https?:\/\//) && (item.indexOf('.') > -1)) { | ||
URI = url.parse(options.base); | ||
URI = url.parse(options.base, false, true); | ||
top = path.dirname(options.path); | ||
@@ -48,3 +48,4 @@ resolved = path.resolve(top, item); | ||
expanded = URI.protocol + '//' + URI.hostname + path.join(URI.pathname, relative).replace(/\\\\|\\/g, '/'); | ||
expanded = (URI.protocol || '') + (URI.hostname ? '//' + URI.hostname : '') + | ||
path.join(URI.pathname, relative).replace(/\\\\|\\/g, '/'); | ||
@@ -57,3 +58,3 @@ str = str.replace(baseItem, baseItem.replace(item, expanded)); | ||
exports.parse = function(options, str, callback) { | ||
var items = str.match(REGEX_FIND); | ||
@@ -60,0 +61,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"author": "Dav Glass <davglass@gmail.com>", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "./lib/index.js", | ||
@@ -8,0 +8,0 @@ "devDependencies": { |
@@ -64,2 +64,10 @@ CSS Relative URL Processor | ||
Base | ||
---- | ||
The value of `base` could be: | ||
* `http://foobar.com/path/to` where protocol will be forced to HTTP | ||
* `https://foobar.com/path/to` where protocol will be forced to SSL | ||
* `//foobar.com/path/to` which is protocol agnostic where it uses the protocol for the css file that contains the images. | ||
* `/path/to` for absolute paths where it uses the domain and protocol from the css file that contains the images. |
@@ -360,3 +360,3 @@ /*jslint maxlen: 500 */ | ||
str += '};\n'; | ||
assert.equal(str, topic); | ||
@@ -412,2 +412,38 @@ } | ||
} | ||
}, | ||
'base as absolute path - /path/to': { | ||
topic: function() { | ||
var str = '.yui-test-cssprocessor {\n'; | ||
str += ' background: url(foo.gif);\n'; | ||
str += '};\n'; | ||
cssproc.parse({ | ||
root: '/home/yui/src/', | ||
path: '/home/yui/src/foo/bar/baz/file.css', | ||
base: '/path/to/build/' | ||
}, str, this.callback); | ||
}, | ||
'and should return /path/to/build/foo.gif': function(topic) { | ||
var str = '.yui-test-cssprocessor {\n'; | ||
str += ' background: url(/path/to/build/foo/bar/baz/foo.gif);\n'; | ||
str += '};\n'; | ||
assert.equal(str, topic); | ||
} | ||
}, | ||
'base without procol - //foobar.com': { | ||
topic: function() { | ||
var str = '.yui-test-cssprocessor {\n'; | ||
str += ' background: url(foo.gif);\n'; | ||
str += '};\n'; | ||
cssproc.parse({ | ||
root: '/home/yui/src/', | ||
path: '/home/yui/src/foo/bar/baz/file.css', | ||
base: '//foobar.com/build/' | ||
}, str, this.callback); | ||
}, | ||
'and should return /path/to/build/foo.gif': function(topic) { | ||
var str = '.yui-test-cssprocessor {\n'; | ||
str += ' background: url(//foobar.com/build/foo/bar/baz/foo.gif);\n'; | ||
str += '};\n'; | ||
assert.equal(str, topic); | ||
} | ||
} | ||
@@ -414,0 +450,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28319
566
73