@antora/redirect-producer
Advanced tools
Comparing version 2.0.1 to 2.1.0-rc.1
@@ -36,5 +36,5 @@ 'use strict' | ||
let siteUrl = playbook.site.url | ||
if (siteUrl && siteUrl.charAt(siteUrl.length - 1) === '/') siteUrl = siteUrl.substr(0, siteUrl.length - 1) | ||
switch (playbook.urls.redirectFacility) { | ||
case 'static': | ||
if (siteUrl && siteUrl.charAt(siteUrl.length - 1) === '/') siteUrl = siteUrl.substr(0, siteUrl.length - 1) | ||
return populateStaticRedirectFiles(aliases, siteUrl) | ||
@@ -44,7 +44,7 @@ case 'netlify': | ||
aliases, | ||
extractUrlContext(siteUrl), | ||
extractUrlPath(siteUrl), | ||
(playbook.urls.htmlExtensionStyle || 'default') === 'default' | ||
) | ||
case 'nginx': | ||
return createNginxRewriteConf(aliases, extractUrlContext(siteUrl)) | ||
return createNginxRewriteConf(aliases, extractUrlPath(siteUrl)) | ||
default: | ||
@@ -55,5 +55,5 @@ return unpublish(aliases) | ||
function extractUrlContext (sourceUrl) { | ||
let urlContext | ||
return sourceUrl && (urlContext = new URL(sourceUrl).pathname) !== '/' ? urlContext : undefined | ||
function extractUrlPath (url) { | ||
let urlPath | ||
return url && (urlPath = new URL(url).pathname) === '/' ? '' : urlPath | ||
} | ||
@@ -69,7 +69,7 @@ | ||
function createNetlifyRedirects (files, urlContext = '', includeDirectoryRedirects = false) { | ||
function createNetlifyRedirects (files, urlPath = '', includeDirectoryRedirects = false) { | ||
const rules = files.reduce((accum, file) => { | ||
delete file.out | ||
const from = `${urlContext}${file.pub.url.replace(ALL_SPACES_RX, '%20')}` | ||
const to = `${urlContext}${file.rel.pub.url.replace(ALL_SPACES_RX, '%20')}` | ||
const from = `${urlPath}${file.pub.url.replace(ALL_SPACES_RX, '%20')}` | ||
const to = `${urlPath}${file.rel.pub.url.replace(ALL_SPACES_RX, '%20')}` | ||
accum.push(`${from} ${to} 301`) | ||
@@ -86,7 +86,7 @@ if (includeDirectoryRedirects && from.endsWith('/index.html')) accum.push(`${from.slice(0, -10)} ${to} 301`) | ||
function createNginxRewriteConf (files, urlContext = '') { | ||
function createNginxRewriteConf (files, urlPath = '') { | ||
const rules = files.map((file) => { | ||
delete file.out | ||
const from = `${urlContext}${file.pub.url.replace(ALL_SPACES_RX, '\\ ')}` | ||
const to = `${urlContext}${file.rel.pub.url.replace(ALL_SPACES_RX, '\\ ')}` | ||
const from = `${urlPath}${file.pub.url.replace(ALL_SPACES_RX, '\\ ')}` | ||
const to = `${urlPath}${file.rel.pub.url.replace(ALL_SPACES_RX, '\\ ')}` | ||
return `location = ${from} { return 301 ${to}; }` | ||
@@ -93,0 +93,0 @@ }) |
{ | ||
"name": "@antora/redirect-producer", | ||
"version": "2.0.1", | ||
"version": "2.1.0-rc.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.0.1", | ||
"@antora/asciidoc-loader": "2.1.0-rc.1", | ||
"vinyl": "~2.2" | ||
@@ -21,0 +21,0 @@ }, |
@@ -15,4 +15,4 @@ # Antora Redirect Producer | ||
Copyright (C) 2017-2018 [OpenDevise Inc.](https://opendevise.com) and the [Antora Project](https://antora.org). | ||
Copyright (C) 2017-2019 [OpenDevise Inc.](https://opendevise.com) and the [Antora Project](https://antora.org). | ||
Use of this software is granted under the terms of the [Mozilla Public License Version 2.0](https://www.mozilla.org/en-US/MPL/2.0/) (MPL-2.0). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7017
1
+ Added@antora/asciidoc-loader@2.1.0-rc.1(transitive)
- Removed@antora/asciidoc-loader@2.0.1(transitive)