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 2.3.0-alpha.1 to 2.3.0-alpha.2

43

lib/produce-redirects.js

@@ -41,4 +41,4 @@ 'use strict'

switch (playbook.urls.redirectFacility) {
case 'static':
return populateStaticRedirectFiles(aliases, siteUrl)
case 'httpd':
return createHttpdHtaccess(aliases, extractUrlPath(siteUrl))
case 'netlify':

@@ -52,2 +52,4 @@ return createNetlifyRedirects(

return createNginxRewriteConf(aliases, extractUrlPath(siteUrl))
case 'static':
return populateStaticRedirectFiles(aliases, siteUrl)
default:

@@ -68,8 +70,13 @@ return unpublish(aliases)

function populateStaticRedirectFiles (files, siteUrl) {
files.forEach((file) => {
file.contents = createStaticRedirectContents(file, siteUrl)
file.mediaType = 'text/html'
})
return []
function createHttpdHtaccess (files, urlPath) {
const rules = files.reduce((accum, file) => {
delete file.out
let fromUrl = file.pub.url
fromUrl = ~fromUrl.indexOf('%20') ? `'${urlPath}${fromUrl.replace(ENCODED_SPACE_RX, ' ')}'` : urlPath + fromUrl
let toUrl = file.rel.pub.url
toUrl = ~toUrl.indexOf('%20') ? `'${urlPath}${toUrl.replace(ENCODED_SPACE_RX, ' ')}'` : urlPath + toUrl
accum.push(`Redirect 301 ${fromUrl} ${toUrl}`)
return accum
}, [])
return [new File({ contents: Buffer.from(rules.join('\n') + '\n'), out: { path: '.htaccess' } })]
}

@@ -88,3 +95,3 @@

}, [])
return [new File({ contents: Buffer.from(rules.join('\n')), out: { path: '_redirects' } })]
return [new File({ contents: Buffer.from(rules.join('\n') + '\n'), out: { path: '_redirects' } })]
}

@@ -101,7 +108,10 @@

})
return [new File({ contents: Buffer.from(rules.join('\n')), out: { path: '.etc/nginx/rewrite.conf' } })]
return [new File({ contents: Buffer.from(rules.join('\n') + '\n'), out: { path: '.etc/nginx/rewrite.conf' } })]
}
function unpublish (files) {
files.forEach((file) => delete file.out)
function populateStaticRedirectFiles (files, siteUrl) {
files.forEach((file) => {
file.contents = Buffer.from(createStaticRedirectContents(file, siteUrl) + '\n')
file.mediaType = 'text/html'
})
return []

@@ -115,3 +125,3 @@ }

const canonicalLink = canonicalUrl ? `<link rel="canonical" href="${canonicalUrl}">\n` : ''
return Buffer.from(`<!DOCTYPE html>
return `<!DOCTYPE html>
<meta charset="utf-8">

@@ -123,5 +133,10 @@ ${canonicalLink}<script>location="${relativeUrl}"</script>

<h1>Redirect Notice</h1>
<p>The page you requested has been relocated to <a href="${relativeUrl}">${canonicalUrl || relativeUrl}</a>.</p>`)
<p>The page you requested has been relocated to <a href="${relativeUrl}">${canonicalUrl || relativeUrl}</a>.</p>`
}
function unpublish (files) {
files.forEach((file) => delete file.out)
return []
}
module.exports = produceRedirects
{
"name": "@antora/redirect-producer",
"version": "2.3.0-alpha.1",
"version": "2.3.0-alpha.2",
"description": "Produces redirects (HTTP redirections) for pages in an Antora site.",

@@ -18,3 +18,3 @@ "license": "MPL-2.0",

"dependencies": {
"@antora/asciidoc-loader": "2.3.0-alpha.1",
"@antora/asciidoc-loader": "2.3.0-alpha.2",
"vinyl": "~2.2"

@@ -21,0 +21,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