@antora/redirect-producer
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -36,3 +36,6 @@ 'use strict' | ||
let siteUrl = playbook.site.url | ||
if (siteUrl && siteUrl.charAt(siteUrl.length - 1) === '/') siteUrl = siteUrl.substr(0, siteUrl.length - 1) | ||
if (siteUrl) { | ||
if (siteUrl === '/') siteUrl = '' | ||
else if (siteUrl.charAt(siteUrl.length - 1) === '/') siteUrl = siteUrl.substr(0, siteUrl.length - 1) | ||
} | ||
switch (playbook.urls.redirectFacility) { | ||
@@ -55,4 +58,8 @@ case 'static': | ||
function extractUrlPath (url) { | ||
let urlPath | ||
return url && (urlPath = new URL(url).pathname) === '/' ? '' : urlPath | ||
if (url) { | ||
if (url.charAt() === '/') return url | ||
const urlPath = new URL(url).pathname | ||
return urlPath === '/' ? '' : urlPath | ||
} | ||
return '' | ||
} | ||
@@ -68,3 +75,3 @@ | ||
function createNetlifyRedirects (files, urlPath = '', includeDirectoryRedirects = false) { | ||
function createNetlifyRedirects (files, urlPath, includeDirectoryRedirects = false) { | ||
const rules = files.reduce((accum, file) => { | ||
@@ -85,3 +92,3 @@ delete file.out | ||
function createNginxRewriteConf (files, urlPath = '') { | ||
function createNginxRewriteConf (files, urlPath) { | ||
const rules = files.map((file) => { | ||
@@ -108,7 +115,7 @@ delete file.out | ||
const relativeUrl = computeRelativeUrlPath(file.pub.url, targetUrl) | ||
const canonicalUrl = siteUrl ? siteUrl + targetUrl : undefined | ||
const canonicalLink = siteUrl ? `\n<link rel="canonical" href="${canonicalUrl}">` : '' | ||
const canonicalUrl = siteUrl && siteUrl.charAt() !== '/' ? siteUrl + targetUrl : undefined | ||
const canonicalLink = canonicalUrl ? `<link rel="canonical" href="${canonicalUrl}">\n` : '' | ||
return Buffer.from(`<!DOCTYPE html> | ||
<meta charset="utf-8">${canonicalLink} | ||
<script>location="${relativeUrl}"</script> | ||
<meta charset="utf-8"> | ||
${canonicalLink}<script>location="${relativeUrl}"</script> | ||
<meta http-equiv="refresh" content="0; url=${relativeUrl}"> | ||
@@ -115,0 +122,0 @@ <meta name="robots" content="noindex"> |
{ | ||
"name": "@antora/redirect-producer", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Produces redirects (HTTP redirections) for pages in an Antora site.", | ||
@@ -18,3 +18,3 @@ "license": "MPL-2.0", | ||
"dependencies": { | ||
"@antora/asciidoc-loader": "2.1.0", | ||
"@antora/asciidoc-loader": "2.1.1", | ||
"vinyl": "~2.2" | ||
@@ -21,0 +21,0 @@ }, |
7152
122
+ Added@antora/asciidoc-loader@2.1.1(transitive)
- Removed@antora/asciidoc-loader@2.1.0(transitive)