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.3.2 to 0.4.0

25

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 || [/.*/];
var html = opt.html || _html;
var rules = opt.rules || [{
match: /<\/body>/,
match: /<\/body>(?![\s\S]*<\/body>)/,
fn: prepend
}, {
match: /<\/html>/,
match: /<\/html>(?![\s\S]*<\/html>)/,
fn: prepend

@@ -18,3 +19,3 @@ }, {

var src = opt.src || "' + (location.protocol || 'http:') + '//' + (location.hostname || 'localhost') + ':" + port + "/livereload.js?snipver=1";
var snippet = "\n<script type=\"text/javascript\">document.write('<script src=\"" + src + "\" type=\"text/javascript\"><\\/script>')</script>\n";
var snippet = "\n<script type=\"text/javascript\">//<![CDATA[\ndocument.write('<script src=\"" + src + "\" type=\"text/javascript\"><\\/script>')\n//]]></script>\n";

@@ -73,12 +74,8 @@ // helper functions

function leave(req) {
var url = req.url;
var ignored = false;
if (!url) return true;
ignore.forEach(function(item) {
if (~url.indexOf(item)) {
ignored = true;
}
function check(str, arr) {
if (!str) return true;
return arr.some(function(item) {
if ( (item.test && item.test(str) ) || ~str.indexOf(item)) return true;
return false;
});
return ignored;
}

@@ -95,3 +92,3 @@

if (!accept(req) || leave(req)) {
if (!accept(req) || !check(req.url, include) || check(req.url, ignore)) {
return next();

@@ -98,0 +95,0 @@ }

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

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

@@ -52,4 +52,9 @@ connect-livereload

```javascript
// these files will be ignored
ignore: ['.js', '.css', '.svg', '.ico', '.woff', '.png', '.jpg', '.jpeg'],
// `ignore` and `include`: array with strings and regex expressions elements.
// strings: included/ignored when the url contains this string
// regex: any expression: e.g. starts with pattern: /^.../ ends with pattern: /...$/
ignore: [/\.js$/, /\.css$/, /\.svg$/, /\.ico$/, /\.woff$/, /\.png$/, /\.jpg$/, /\.jpeg$/],
// include all urls by default
include: [/.*/],

@@ -66,6 +71,6 @@ // this function is used to determine if the content of `res.write` or `res.end` is html.

rules: [{
match: /<\/body>/,
match: /<\/body>(?![\s\S]*<\/body>)/,
fn: prepend
}, {
match: /<\/html>/,
match: /<\/html>(?![\s\S]*<\/html>)/,
fn: prepend

@@ -72,0 +77,0 @@ }, {

Sorry, the diff of this file is not supported yet

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