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

browser-sync

Package Overview
Dependencies
Maintainers
1
Versions
300
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-sync - npm Package Compare versions

Comparing version 0.5.3 to 0.5.4

19

lib/config.js

@@ -9,2 +9,5 @@ /*

|
| For up-to-date information about the options:
| https://github.com/shakyShane/browser-sync/wiki/Working-with-a-Config-File
|
*/

@@ -179,4 +182,18 @@ module.exports = {

*/
host: null
host: null,
/*
|--------------------------------------------------------------------------
| Excluded File Types
|--------------------------------------------------------------------------
|
| If you find a certain file-type is not working well with the proxy/server
| add the file extension here.
|
| eg:
| excludedFileTypes: ["ogg", "mp4"]
|
*/
excludedFileTypes: []
};

@@ -14,6 +14,3 @@ #! /usr/bin/env node

debugInfo: true,
background: false,
defaultConfig: true,
reloadFileTypes: ["php", "html", "js", "erb"],
injectFileTypes: ["css", "png", "jpg", "jpeg", "svg", "gif"],
injectFileTypes: ["css", "png", "jpg", "jpeg", "svg", "gif", "webp"],
host: null,

@@ -34,4 +31,31 @@ ghostMode: {

scrollThrottle: 0,
injectChanges: true
injectChanges: true,
excludedFileTypes: [
"js",
"css",
"svg",
"ico",
"woff",
"json",
"eot",
"ttf",
"png",
"jpg",
"jpeg",
"webp",
"gif",
"mp4",
"mp3",
"3gp",
"ogg",
"ogv",
"webm",
"m4a",
"flv",
"wmv",
"avi",
"swf"
]
};
module.exports.defaultConfig = defaultConfig;

@@ -89,3 +113,3 @@ var info = {

if (config) {
return _.extend(defaultConfig, config);
return this.mergeConfigObjects(defaultConfig, config);
}

@@ -96,5 +120,22 @@

/**
* Merge user-given file extensions with defaults
* @param {Object} defaultConfig
* @param {Object} config
* @returns {Object}
* @private
*/
_mergeExcluded: function (defaultConfig, config) {
var excluded = config.excludedFileTypes;
if (excluded && Array.isArray(excluded)) {
config.excludedFileTypes = _.union(defaultConfig.excludedFileTypes, excluded);
}
return config;
},
/**
* @returns {Object}
* @private
*/
_getDefaultConfigFile: function () {

@@ -296,6 +337,10 @@ var defaultPath = process.cwd() + messages.configFile;

* Accept a user-provided config object and merge with default
* @param {Object} defaultConfig
* @param {Object} userConfig
* @returns {Object}
*/
mergeConfig: function (defaultConfig, userConfig) {
mergeConfigObjects: function (defaultConfig, userConfig) {
if (userConfig && userConfig.excludedFileTypes) {
userConfig = this._mergeExcluded(defaultConfig, userConfig);
}
var merged = _.merge(defaultConfig, userConfig);

@@ -405,4 +450,5 @@ return merged;

if (userConfig) {
config = setup.mergeConfig(defaultConfig, userConfig || {});
config = setup.mergeConfigObjects(defaultConfig, userConfig || {});
if (files && userConfig.exclude) {

@@ -409,0 +455,0 @@ files = setup.mergeFiles(files, userConfig.exclude);

2

lib/loadSnippet.js

@@ -18,3 +18,3 @@ "use strict";

if (utils.isExcluded(req)) {
if (utils.isExcluded(req.url, options.excludedFileTypes)) {
return next();

@@ -21,0 +21,0 @@ }

@@ -71,3 +71,3 @@ "use strict";

// Alter accept-encoding header to ensure plain-text response
req.headers["accept-encoding"] = "*;q=1,gzip=0";
req.headers["accept-encoding"] = "identity";

@@ -82,3 +82,3 @@ var next = function () {

if (snippetUtils.isExcluded(req)) {
if (snippetUtils.isExcluded(req.url, options.excludedFileTypes)) {
return next();

@@ -102,2 +102,2 @@ }

return server;
};
};

@@ -59,2 +59,6 @@ "use strict";

if (req.method !== "GET") {
return false;
}
if (headers["x-requested-with"] !== undefined && headers["x-requested-with"] === "XMLHttpRequest") {

@@ -68,3 +72,3 @@ return false;

if (snippetUtils.isExcluded(req) || req.method !== "GET") {
if (snippetUtils.isExcluded(req.url, options.excludedFileTypes)) {
return false;

@@ -71,0 +75,0 @@ }

"use strict";
var path = require("path");
var _ = require("lodash");
/**

@@ -11,20 +14,2 @@ *

var utils = {
/**
* requests to ignore
*/
excludeList: [
".js",
".css",
".svg",
".ico",
".woff",
".eot",
".ttf",
".png",
".jpg",
".jpeg",
".gif",
"json"
],
bodyPattern: /<body[^>]*>/i,

@@ -44,18 +29,16 @@

/**
*
* @param req
* @param {String} url
* @param {Array} excludeList
* @returns {boolean}
*/
isExcluded: function (req) {
var url = req.url;
var excluded = false;
if (!url) {
return true;
isExcluded: function (url, excludeList) {
var extension = path.extname(url);
if (extension) {
extension = extension.slice(1);
return _.contains(excludeList, extension);
}
this.excludeList.forEach(function(exclude) {
if (~url.indexOf(exclude)) {
excluded = true;
}
});
return excluded;
return false;
}

@@ -62,0 +45,0 @@ };

{
"name": "browser-sync",
"description": "Live CSS Reload & Browser Syncing",
"version": "0.5.3",
"version": "0.5.4",
"homepage": "https://github.com/shakyshane/browser-sync",

@@ -6,0 +6,0 @@ "author": {

Sorry, the diff of this file is not supported yet

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