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

@antora/redirect-producer

Package Overview
Dependencies
Maintainers
2
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antora/redirect-producer - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

30

lib/produce-redirects.js

@@ -39,18 +39,10 @@ 'use strict'

if (siteUrl) siteUrl = stripTrailingSlash(siteUrl, '')
const directoryRedirects = (playbook.urls.htmlExtensionStyle || 'default') !== 'default'
switch (playbook.urls.redirectFacility) {
case 'gitlab':
return createNetlifyRedirects(
aliases,
extractUrlPath(siteUrl),
(playbook.urls.htmlExtensionStyle || 'default') === 'default',
false
)
return createNetlifyRedirects(aliases, extractUrlPath(siteUrl), !directoryRedirects, false)
case 'httpd':
return createHttpdHtaccess(aliases, extractUrlPath(siteUrl))
return createHttpdHtaccess(aliases, extractUrlPath(siteUrl), directoryRedirects)
case 'netlify':
return createNetlifyRedirects(
aliases,
extractUrlPath(siteUrl),
(playbook.urls.htmlExtensionStyle || 'default') === 'default'
)
return createNetlifyRedirects(aliases, extractUrlPath(siteUrl), !directoryRedirects)
case 'nginx':

@@ -78,3 +70,3 @@ return createNginxRewriteConf(aliases, extractUrlPath(siteUrl))

function createHttpdHtaccess (files, urlPath) {
function createHttpdHtaccess (files, urlPath, directoryRedirects = false) {
const rules = files.reduce((accum, file) => {

@@ -88,3 +80,9 @@ delete file.out

// NOTE: redirect rule for directory prefix does not require trailing slash
accum.push(`Redirect ${file.pub.splat ? '302' : '301'} ${fromUrl} ${stripTrailingSlash(toUrl)}`)
if (file.pub.splat) {
accum.push(`Redirect 302 ${fromUrl} ${stripTrailingSlash(toUrl)}`)
} else if (directoryRedirects) {
accum.push(`RedirectMatch 301 ^${regexpEscape(fromUrl)}$ ${stripTrailingSlash(toUrl)}`)
} else {
accum.push(`Redirect 301 ${fromUrl} ${toUrl}`)
}
return accum

@@ -98,3 +96,3 @@ }, [])

// however, we keep it when generating the rules for clarity
function createNetlifyRedirects (files, urlPath, includeDirectoryRedirects = false, useForceFlag = true) {
function createNetlifyRedirects (files, urlPath, addDirectoryRedirects = false, useForceFlag = true) {
const rules = files.reduce((accum, file) => {

@@ -109,3 +107,3 @@ delete file.out

accum.push(`${fromUrl} ${toUrl} 301${forceFlag}`)
if (includeDirectoryRedirects && fromUrl.endsWith('/index.html')) {
if (addDirectoryRedirects && fromUrl.endsWith('/index.html')) {
accum.push(`${fromUrl.substr(0, fromUrl.length - 10)} ${toUrl} 301${forceFlag}`)

@@ -112,0 +110,0 @@ }

{
"name": "@antora/redirect-producer",
"version": "3.0.2",
"version": "3.0.3",
"description": "Produces redirects (HTTP redirections) for pages in an Antora site.",

@@ -5,0 +5,0 @@ "license": "MPL-2.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