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

connect-livereload

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-livereload - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

21

index.js
module.exports = function livereload(opt) {
// options
var opt = opt || {};
var ignore = opt.ignore || opt.excludeList || [/\.js$/, /\.css$/, /\.svg$/, /\.ico$/, /\.woff$/, /\.png$/, /\.jpg$/, /\.jpeg$/];
var ignore = opt.ignore || opt.excludeList ||
[/\.js(\?.*)?$/, /\.css(\?.*)?$/, /\.svg(\?.*)?$/, /\.ico(\?.*)?$/, /\.woff(\?.*)?$/, /\.png(\?.*)?$/, /\.jpg(\?.*)?$/, /\.jpeg(\?.*)?$/];
var include = opt.include || [/.*/];

@@ -114,11 +115,11 @@ var html = opt.html || _html;

var body = string instanceof Buffer ? string.toString(encoding) : string;
// If this chunk must receive a snip, do so
if (exists(body) && !snip(res.data)) {
res.push(snap(body));
return true;
} else if (html(body) || html(res.data)) {
}
// If in doubt, simply buffer the data for later inspection (on `end` function)
else {
res.push(body);
return true;
} else {
restore();
return write.call(res, string, encoding);
}

@@ -146,5 +147,11 @@ }

res.end = function(string, encoding) {
// If there are remaining bytes, save them as well
// Also, some implementations call "end" directly with all data.
res.inject(string);
restore();
var result = res.inject(string, encoding);
if (!result) return end.call(res, string, encoding);
// Check if our body is HTML, and if it does not already have the snippet.
if (html(res.data) && exists(res.data) && !snip(res.data)) {
// Include, if necessary, replacing the entire res.data with the included snippet.
res.data = snap(res.data);
}
if (res.data !== undefined && !res._header) res.setHeader('content-length', Buffer.byteLength(res.data, encoding));

@@ -151,0 +158,0 @@ res.end(res.data, encoding);

{
"name": "connect-livereload",
"description": "connect middleware for adding the livereload script to the response",
"version": "0.4.1",
"version": "0.5.0",
"author": "Andi Neck <andi.neck@intesso.com>",

@@ -6,0 +6,0 @@ "contributors": [

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