Comparing version 0.1.2 to 0.1.3
@@ -328,3 +328,2 @@ var OO = require( 'oojs' ), | ||
res = this.resources, | ||
lang = this.constructor.static.resourceLanguages[type], | ||
format = this.constructor.static.resourceFormats[type]; | ||
@@ -336,4 +335,2 @@ | ||
options = ( options && options[lang] ) || {}; | ||
if ( format === 'object' ) { | ||
@@ -340,0 +337,0 @@ out = {}; |
@@ -33,2 +33,6 @@ var OO = require( 'oojs' ), | ||
* @inheritdoc | ||
* | ||
* @param {string} file File name | ||
* @param {Object} [options] Generation options | ||
* @param {boolean} [staticRoot] Base URL for static file access | ||
*/ | ||
@@ -43,2 +47,6 @@ StylesheetResource.prototype.mapFileToContent = function *( file, options ) { | ||
if ( options && options.staticRoot ) { | ||
css = this.remap( css, file, options.staticRoot ); | ||
} | ||
return css; | ||
@@ -74,4 +82,34 @@ }; | ||
StylesheetResource.prototype.remap = function ( data, fileName, staticRoot ) { | ||
if ( data && staticRoot ) { | ||
return data.replace( /url\s*\(\s*(['"]?)([^"'\)]*)\1\s*\)/gi, function ( match ) { | ||
var url, urlPath, | ||
dirName = path.resolve( path.dirname( fileName ) ); | ||
match = match.replace( /\s/g, '' ); | ||
url = match.slice( 4, -1 ) | ||
.replace( /"|'/g, '' ) | ||
.replace( /\\/g, '/' ); | ||
if ( | ||
/^\/|https:|http:|data:/i.test( url ) === false && | ||
dirName.indexOf( staticRoot ) > -1 | ||
) { | ||
urlPath = path.resolve( dirName + '/' + url ); | ||
if ( urlPath.indexOf( staticRoot ) > -1 ) { | ||
url = staticRoot + urlPath | ||
.substr( urlPath.indexOf( staticRoot ) + staticRoot.length ) | ||
.replace( /\\/g, '/' ); | ||
} | ||
} | ||
return 'url("' + url + '")'; | ||
} ); | ||
} | ||
return data; | ||
}; | ||
/* Exports */ | ||
module.exports = StylesheetResource; |
{ | ||
"name": "palo", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
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
26710
840