From 3ed32563f0d25b33bc89e50b0bbc03e57a8bbcea Mon Sep 17 00:00:00 2001 From: mswaidan Date: Tue, 12 Nov 2019 13:47:17 -0500 Subject: [PATCH 1/2] Small fix to remove duplicate forward slash from pl.canonicalUrl --- plugins.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins.js b/plugins.js index 779c335e..2d682997 100644 --- a/plugins.js +++ b/plugins.js @@ -43,7 +43,15 @@ module.exports = ( ) => { It will load from ${pl.serveFrom + '-dupe'} instead.` ) pl.serveFrom += '-dupe' } - pl.canonicalUrl = process.env.CANONICAL_URL + pl.serveFrom + //trim extra leading slash from serveFrom if necessary + const canonicalUrl = process.env.CANONICAL_URL + const lastBaseChar = canonicalUrl.charAt( canonicalUrl.length - 1 ) + const firstServeFromChar = pl.serveFrom.charAt( 0 ) + if ( lastBaseChar === '/' && firstServeFromChar === '/' ) { + pl.canonicalUrl = process.env.CANONICAL_URL + pl.serveFrom.slice( 1 ) + + } + else pl.canonicalUrl = process.env.CANONICAL_URL + pl.serveFrom } ) winston.debug( `Found ${plugins.length} plugin(s): ${plugins.map( p => p.name ).join( ', ' )}` ) From 9c89d578039cfe96447720f38fe215aed9153b81 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 21 Nov 2019 11:25:51 +0000 Subject: [PATCH 2/2] fix(plugins): creates serve from url properly --- plugins.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/plugins.js b/plugins.js index 2d682997..721990a0 100644 --- a/plugins.js +++ b/plugins.js @@ -43,15 +43,9 @@ module.exports = ( ) => { It will load from ${pl.serveFrom + '-dupe'} instead.` ) pl.serveFrom += '-dupe' } - //trim extra leading slash from serveFrom if necessary - const canonicalUrl = process.env.CANONICAL_URL - const lastBaseChar = canonicalUrl.charAt( canonicalUrl.length - 1 ) - const firstServeFromChar = pl.serveFrom.charAt( 0 ) - if ( lastBaseChar === '/' && firstServeFromChar === '/' ) { - pl.canonicalUrl = process.env.CANONICAL_URL + pl.serveFrom.slice( 1 ) - } - else pl.canonicalUrl = process.env.CANONICAL_URL + pl.serveFrom + pl.canonicalUrl = new URL( pl.serveFrom, process.env.CANONICAL_URL ) + } ) winston.debug( `Found ${plugins.length} plugin(s): ${plugins.map( p => p.name ).join( ', ' )}` )