vendor/lib/functions/url.js in stylus-source-0.28.2 vs vendor/lib/functions/url.js in stylus-source-0.29.0
- old
+ new
@@ -49,28 +49,27 @@
*/
module.exports = function(options) {
options = options || {};
- var sizeLimit = options.limit || 30000
- , _paths = options.paths || [];
+ var _paths = options.paths || [];
+ var sizeLimit = null != options.sizeLimit ? options.sizeLimit : 30000;
- function url(url){
+ function fn(url){
// Compile the url
var compiler = new Compiler(url);
compiler.isURL = true;
- var url = url.nodes.map(function(node){
+ url = url.nodes.map(function(node){
return compiler.visit(node);
}).join('');
- // Parse literal
- var url = parse(url)
- , ext = extname(url.pathname)
+ // Parse literal
+ url = parse(url);
+ var ext = extname(url.pathname)
, mime = mimes[ext]
, literal = new nodes.Literal('url("' + url.href + '")')
, paths = _paths.concat(this.paths)
- , founds
, buf;
// Not supported
if (!mime) return literal;
@@ -85,14 +84,14 @@
// Read data
buf = fs.readFileSync(found);
// To large
- if (buf.length > sizeLimit) return literal;
+ if (false !== sizeLimit && buf.length > sizeLimit) return literal;
// Encode
return new nodes.Literal('url("data:' + mime + ';base64,' + buf.toString('base64') + '")');
};
- url.raw = true;
- return url;
-};
\ No newline at end of file
+ fn.raw = true;
+ return fn;
+};