New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-hash-src

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-hash-src - npm Package Compare versions

Comparing version 0.0.4 to 0.1.0

23

hash-src.js

@@ -8,4 +8,3 @@ // jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, onevar: true, strict:true, undef:true, unused:true, curly:true, node:true, newcap:true

girdle = require("girdle"),
p = require("path"),
p,
find_regex = /(href|src)\s*=\s*(?:(")([^"]*)|(')([^']*)|([^'"\s>]+))|url\s*\((?:(")([^"]+)|(')([^']+)|([^'"\)]+))/ig;

@@ -39,4 +38,4 @@

/// Is it relative
if (link[0] !== "/" && base && !is_abs_link(link)) {
link = p.join(base, link)
if (base && link[0] !== "/" && !is_abs_link(link)) {
link = p.join(base, link);
}

@@ -74,2 +73,4 @@

p = fs_helper.p;
module.exports = function hash_src(options)

@@ -90,6 +91,8 @@ {

if (!options.exts) {
options.exts = [".js", ".css", ".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".pdf", ".ico", ".ttf", ".woff", ".mp3", ".ogg", ".ogv", ".mp4", ".webm"];
options.exts = [".js", ".css", ".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".pdf", ".ico", ".ttf", ".woff", ".mp3", ".ogg", ".ogv", ".mp4", ".webm", ".zip", ".tar", ".gz", ".bz2"];
}
if (!options.regex || !options.analyze) {
if (!options.regex) {
options.regex = find_regex;
}
if (!options.analyze) {
options.analyze = analyze;

@@ -133,4 +136,5 @@ }

{
if (options.hash_len)
hash = hash.substring(hash, options.hash_len);
if (options.hash_len) {
hash = hash.substring(hash, options.hash_len);
}
hashes[link] = hash;

@@ -161,3 +165,2 @@ next();

function hash_it(file, encoding, callback)

@@ -168,3 +171,3 @@ {

get_hashes(data, base, function onhash(err)
get_hashes(data, base, function onhash()
{

@@ -171,0 +174,0 @@ file.contents = new Buffer(rewrite(data, base));

{
"name": "gulp-hash-src",
"description": "Add hashes to links in HTML/CSS",
"version": "0.0.4",
"version": "0.1.0",
"author": {

@@ -10,5 +10,5 @@ "name": "Nathan Rugg",

"dependencies": {
"through2": "^0.4.2",
"fs_helper": "^0.1.9",
"girdle": "^0.1.12"
"through2": "=0.4.2",
"fs_helper": "=0.1.11",
"girdle": "=0.2.2"
},

@@ -15,0 +15,0 @@ "keywords": [

# gulp-hash-src
<strong>DANGER: This is a 0.0.x release.</strong>
Automatically add cache busting hashes to links in HTML and CSS.

@@ -64,8 +62,9 @@

hash_len The length of a string to extract from hash
hash_len The length of the hash (default: null)
If hash_len is falsey, the entire hash is used.
enc Encoding (default: "hex")
enc Hash encoding (default: "hex")
exts An array of the types of files to hash
(default: [".js", ".css", ".jpg", ".jpeg", ".png", ".gif", ".svg", ".pdf", ".ico", ".ttf", ".woff"])
(default: [".js", ".css", ".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".pdf", ".ico", ".ttf", ".woff", ".mp3", ".ogg", ".ogv", ".mp4", ".webm", ".zip", ".tar", ".gz", ".bz2"])

@@ -76,8 +75,9 @@ regex The regular expression to find links

analyze The function to use to analyze the regular expression matches
Must return an object like so
The function will receive an array of the matches from the regex.
Must return an object like so:
{
prefix: "href=",
link: "/file.js",
suffix: ""
abs: false
suffix: "",
abs: false (optional)
}

@@ -84,0 +84,0 @@

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