Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-appolo-assets-url-replace

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-appolo-assets-url-replace - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

package.json~

2

package.json
{
"name": "grunt-appolo-assets-url-replace",
"description": "Grunt task to replace assets urls with absolute path",
"version": "0.0.4",
"version": "0.0.5",
"author": {

@@ -6,0 +6,0 @@ "name": "Roman Svichar",

@@ -10,6 +10,5 @@

//var imgRegex = /url\s?\(['"]?(.*?)(?=['"]?\))/gi;
var cssRegex = /url\s*\(\s*(['"]?)([^"'\)]*)\1\s*\)/gi;
var htmlRegex = /src\s?\=['"]?(.*)['"]/gi;
var htmlRegexSrc = /src\s?\=['"]?(.*)['"]/gi;
var htmlRegexHref = /href\s?\=['"]?(.*)['"]/gi;

@@ -23,3 +22,3 @@

staticUrl: 'public',
ext: ['.png', '.jpeg', '.jpg', '.gif']
ext: ['.png', '.jpeg', '.jpg', '.gif', '.js', '.css']
});

@@ -63,3 +62,3 @@

while(match = htmlRegex.exec(html)) {
while(match = htmlRegexSrc.exec(html)) {
var imagePath = match[1];

@@ -71,3 +70,3 @@

options.ext.indexOf(path.extname(imagePath)) > -1 ) {
html = html.replace(match[0], 'src="'+options.staticUrl + path.normalize('/'+ imagePath)+'"');
html = html.replace(match[0], 'src="'+ options.staticUrl + path.normalize('/'+ imagePath)+'"');
modified = true;

@@ -77,2 +76,14 @@ }

while(match = htmlRegexHref.exec(html)) {
var imagePath = match[1];
if (imagePath.indexOf("http://") == -1 &&
imagePath.indexOf("https://") == -1 &&
imagePath.indexOf(";base64") == -1 &&
options.ext.indexOf(path.extname(imagePath)) > -1 ) {
html = html.replace(match[0], 'href="'+ options.staticUrl + path.normalize('/'+ imagePath)+'"');
modified = true;
}
}
if(modified) {

@@ -79,0 +90,0 @@ grunt.file.write(filepath, html);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc