Skip to content

Commit

Permalink
Work around URL issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Jul 6, 2018
1 parent 5199a8b commit fcdc508
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions routes/appendLocals.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path');
const url = require('url');
const helpers = require('../lib/helpers.js');
const config = require('../config');

Expand Down Expand Up @@ -38,8 +39,8 @@ function getThemeQuery(req) {
return query;
}

function generateBodyClass(url) {
let str = url;
function generateBodyClass(pageUrl) {
let str = url.parse(pageUrl).pathname;

if (str === '/') {
str = 'home'; // only for the index page
Expand All @@ -63,7 +64,7 @@ function generateSRI(file) {

function appendLocals(req, res) {
const siteUrl = getCurrentSiteurl(req);
const canonicalUrl = `${config.siteurl}${req.originalUrl}`;
const canonicalUrl = config.siteurl + url.parse(`${req.originalUrl}`).pathname;
const theme = getThemeQuery(req);
const pageUrl = req.originalUrl;
const bodyClass = generateBodyClass(pageUrl);
Expand Down

0 comments on commit fcdc508

Please sign in to comment.