netlify-plugin-submit-sitemap
Advanced tools
Comparing version 0.2.1 to 0.2.2
18
index.js
@@ -43,3 +43,3 @@ const url = require('url'); | ||
// helper | ||
// helpers | ||
const removeEmptyValues = (obj) => { | ||
@@ -54,2 +54,9 @@ return Object.keys(obj) | ||
// Make sure the url is prepended with 'https://' | ||
const prependScheme = (baseUrl) => { | ||
return baseUrl.match(/^[a-zA-Z]+:\/\//) | ||
? baseUrl | ||
: baseUrl = `https://${baseUrl}`; | ||
} | ||
module.exports = { | ||
@@ -60,3 +67,2 @@ async onSuccess({ utils, inputs }) { | ||
} | ||
const sitemapUrl = (new url.URL(sitemapPath, baseUrl)).href; | ||
@@ -69,2 +75,10 @@ // Only run on production branch | ||
let sitemapUrl; | ||
const baseUrlWithScheme = prependScheme(baseUrl); | ||
try { | ||
sitemapUrl = (new url.URL(sitemapPath, baseUrlWithScheme)).href; | ||
} catch(error) { | ||
return utils.build.failPlugin(`Invalid sitemap URL! baseUrl: ${baseUrlWithScheme}, sitemapPath: ${sitemapPath}`, { error }); | ||
} | ||
// submit sitemap to all providers | ||
@@ -71,0 +85,0 @@ const submissions = await Promise.all( |
{ | ||
"name": "netlify-plugin-submit-sitemap", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Automatically submit your sitemap to Google, Bing, and Yandex!", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
5834
96