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

gulp-sitemap

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-sitemap - npm Package Compare versions

Comparing version 5.1.0 to 6.0.0

34

index.js
'use strict';
var chalk = require('chalk');
var defaults = require('lodash/defaults');
var log = require('fancy-log');
var path = require('path');
var PluginError = require('plugin-error');
var through = require('through2');
var Vinyl = require('vinyl');
const chalk = require('chalk');
const defaults = require('lodash/defaults');
const log = require('fancy-log');
const path = require('path');
const PluginError = require('plugin-error');
const through = require('through2');
const Vinyl = require('vinyl');
var pluginName = 'gulp-sitemap';
var sitemap = require('./lib/sitemap');
const pluginName = 'gulp-sitemap';
const sitemap = require('./lib/sitemap');
module.exports = function (options) {
var config = defaults(options || {}, {
module.exports = function (options = {}) {
const config = defaults({}, options, {
changefreq: undefined,

@@ -24,5 +24,5 @@ fileName: 'sitemap.xml',

});
var entries = [];
var firstFile;
var msg;
const entries = [];
let firstFile;
let msg;

@@ -62,3 +62,3 @@ if (!config.siteUrl) {

var entry = sitemap.getEntryConfig(file, config);
const entry = sitemap.getEntryConfig(file, config);
entries.push(entry);

@@ -71,3 +71,3 @@ callback();

}
var contents = sitemap.prepareSitemap(entries, config);
const contents = sitemap.prepareSitemap(entries, config);
if (options.verbose) {

@@ -82,3 +82,3 @@ msg = 'Files in sitemap: ' + entries.length;

path: path.join(firstFile.cwd, config.fileName),
contents: new Buffer(contents)
contents: Buffer.from(contents)
}));

@@ -85,0 +85,0 @@ callback();

'use strict';
var defaults = require('lodash/defaults');
var find = require('lodash/find');
var includes = require('lodash/includes');
var multimatch = require('multimatch');
var slash = require('slash');
var pick = require('lodash/pick');
const defaults = require('lodash/defaults');
const find = require('lodash/find');
const includes = require('lodash/includes');
const multimatch = require('multimatch');
const slash = require('slash');
const pick = require('lodash/pick');
var header = [
const header = [
'<?xml version="1.0" encoding="UTF-8"?>',

@@ -14,3 +14,3 @@ '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'

var headerHref = [
const headerHref = [
'<?xml version="1.0" encoding="UTF-8"?>',

@@ -20,12 +20,12 @@ '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">'

var footer = ['</urlset>'];
var allowedProperties = ['getLoc', 'lastmod', 'priority', 'changefreq', 'hreflang'];
const footer = ['</urlset>'];
const allowedProperties = ['getLoc', 'lastmod', 'priority', 'changefreq', 'hreflang'];
function getEntryConfig(file, siteConfig) {
var relativePath = file.relative;
var mappingsForFile = find(siteConfig.mappings, function(item) {
const relativePath = file.relative;
const mappingsForFile = find(siteConfig.mappings, function(item) {
return multimatch(relativePath, item.pages).length > 0;
}) || {};
var entry = defaults(
const entry = defaults(
{},

@@ -44,6 +44,8 @@ pick(mappingsForFile, allowedProperties),

//turn index.html into -> /
var relativeFile = relativePath.replace(/(\/|\\|^)index\.html?$/, '/');
if (relativeFile === '/') relativeFile = ''
let relativeFile = relativePath.replace(/(\/|\\|^)index\.html?$/, '/');
if (relativeFile === '/') {
relativeFile = '';
}
//url location. Use slash to convert windows \\ or \ to /
var adjustedFile = slash(relativeFile);
const adjustedFile = slash(relativeFile);
entry.loc = siteConfig.siteUrl + adjustedFile;

@@ -64,11 +66,11 @@ entry.file = adjustedFile;

* @param siteConfig
* @return {Array}
* @return {string}
*/
function processEntry(entry, siteConfig) {
var returnArr = [siteConfig.spacing + '<url>'];
const returnArr = [siteConfig.spacing + '<url>'];
var loc = entry.getLoc ? entry.getLoc(siteConfig.siteUrl, entry.loc, entry) : entry.loc;
const loc = entry.getLoc ? entry.getLoc(siteConfig.siteUrl, entry.loc, entry) : entry.loc;
returnArr.push(siteConfig.spacing + siteConfig.spacing + wrapTag('loc', loc));
var lastmod = entry.lastmod;
let lastmod = entry.lastmod;
if (lastmod) {

@@ -80,3 +82,3 @@ //format mtime to ISO (same as +00:00)

var changefreq = entry.changefreq;
const changefreq = entry.changefreq;
if (changefreq) {

@@ -86,3 +88,3 @@ returnArr.push(siteConfig.spacing + siteConfig.spacing + wrapTag('changefreq', changefreq));

var priority = entry.priority;
const priority = entry.priority;
if (priority || priority === 0) {

@@ -92,8 +94,8 @@ returnArr.push(siteConfig.spacing + siteConfig.spacing + wrapTag('priority', priority));

var hreflang = entry.hreflang;
const hreflang = entry.hreflang;
if (hreflang && hreflang.length > 0) {
var file = entry.file;
const file = entry.file;
hreflang.forEach(function(item) {
var href = item.getHref(siteConfig.siteUrl, file, item.lang, loc);
var tag = '<xhtml:link rel="alternate" hreflang="' + item.lang + '" href="' + href + '" />';
const href = item.getHref(siteConfig.siteUrl, file, item.lang, loc);
const tag = '<xhtml:link rel="alternate" hreflang="' + item.lang + '" href="' + href + '" />';
returnArr.push(siteConfig.spacing + siteConfig.spacing + tag);

@@ -108,3 +110,3 @@ });

function prepareSitemap(entries, config) {
var entriesHref = entries.some(function(entry) {
const entriesHref = entries.some(function(entry) {
return entry && entry.hreflang && entry.hreflang.length;

@@ -121,3 +123,3 @@ });

var validChangefreqs = [
const VALID_CHANGE_FREQUENCIES = [
'always',

@@ -137,3 +139,3 @@ 'hourly',

}
return includes(validChangefreqs, changefreq.toLowerCase());
return includes(VALID_CHANGE_FREQUENCIES, changefreq.toLowerCase());
}

@@ -140,0 +142,0 @@

{
"name": "gulp-sitemap",
"version": "5.1.0",
"version": "6.0.0",
"description": "Generate a search engine friendly sitemap.xml using a Gulp stream",

@@ -18,6 +18,5 @@ "repository": "pgilad/gulp-sitemap",

"engines": {
"node": ">=4.0.0"
"node": ">=6.14.4"
},
"scripts": {
"watchTest": "mocha -R spec --watch test/*.spec.js",
"test": "mocha -R spec test/*.spec.js"

@@ -38,17 +37,18 @@ },

"dependencies": {
"chalk": "^1.1.1",
"chalk": "^2.4.1",
"fancy-log": "^1.3.2",
"lodash": "^4.6.1",
"lodash": "^4.17.11",
"multimatch": "^2.0.0",
"plugin-error": "^0.1.2",
"slash": "^1.0.0",
"plugin-error": "^1.0.1",
"slash": "^2.0.0",
"through2": "^2.0.0",
"vinyl": "^2.1.0"
"vinyl": "^2.2.0"
},
"devDependencies": {
"gulp": "^3.8.11",
"gulp-rename": "^1.2.2",
"mocha": "^3.0.2",
"should": "^11.1.0"
"gulp": "^4.0.0",
"gulp-rename": "^1.4.0",
"mocha": "^5.2.0",
"should": "^13.2.3",
"strip-ansi": "^4.0.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