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 4.0.0 to 4.1.0

4

index.js

@@ -58,4 +58,4 @@ 'use strict';

}
var mtime = file.stat ? file.stat.mtime : null;
var entry = sitemap.getEntryConfig(file.relative, mtime, config);
var entry = sitemap.getEntryConfig(file, config);
entries.push(entry);

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

@@ -9,3 +9,2 @@ 'use strict';

//TODO: export this to an external module
var header = [

@@ -16,22 +15,32 @@ '<?xml version="1.0" encoding="UTF-8"?>',

var headerHref = [
'<?xml version="1.0" encoding="UTF-8"?>',
'<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'];
function getEntryConfig(file, fileLastMod, siteConfig) {
function getEntryConfig(file, siteConfig) {
var relativePath = file.relative;
var mappingsForFile = find(siteConfig.mappings, function(item) {
return multimatch(file, item.pages).length > 0;
return multimatch(relativePath, item.pages).length > 0;
}) || {};
var properties = ['getLoc', 'lastmod', 'priority', 'changefreq', 'hreflang'];
var entry = defaults(
pick(mappingsForFile, properties),
pick(siteConfig, properties)
{},
pick(mappingsForFile, allowedProperties),
pick(siteConfig, allowedProperties)
);
if (entry.lastmod === null) {
entry.lastmod = fileLastMod || Date.now();
// calculate mtime manually
entry.lastmod = file.stat && file.stat.mtime || Date.now();
} else if (typeof entry.lastmod === 'function') {
entry.lastmod = entry.lastmod(file);
}
const indexRegex = /(\/|^)index\.html?$/;
//turn index.html into -> /
var relativeFile = file.replace(/(\/index\.html?|^index\.html?)$/, function(string, match) {
var relativeFile = relativePath.replace(indexRegex, function(string, match) {
return match.slice(0, 1) === '/' ? '/' : '';

@@ -55,3 +64,3 @@ }, 'i');

* @param entry
* @param config
* @param siteConfig
* @return {Array}

@@ -97,3 +106,6 @@ */

function prepareSitemap(entries, config) {
return header
var entriesHref = entries.some(function(entry) {
return entry && entry.hreflang && entry.hreflang.length;
});
return (entriesHref ? headerHref : header)
.concat(entries.map(function(entry) {

@@ -100,0 +112,0 @@ return processEntry(entry, config);

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

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

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