Skip to content
Permalink
Browse files

Restored update for fake categories in URL

  • Loading branch information...
Mathachew committed Sep 20, 2016
1 parent d0ccfca commit 9580b97bfc43d7a4900be7ea7ae695e85d24935e
Showing with 13 additions and 2 deletions.
  1. +12 −1 core/server/controllers/frontend/post-lookup.js
  2. +1 −1 core/server/utils/index.js
@@ -22,6 +22,11 @@ function postLookup(postUrl) {
postParams,
params;

if (postUrl.split('/').length > 3) {
postPermalink = '/:category' + postPermalink;
pagePermalink = '/:category' + pagePermalink;
}

// Convert saved permalink into a path-match function
matchFuncPost = routeMatch(getOptionsFormat(postPermalink));
matchFuncPage = routeMatch(getOptionsFormat(pagePermalink));
@@ -49,7 +54,13 @@ function postLookup(postUrl) {
}

// Sanitize params we're going to use to lookup the post.
params = _.pick(params, 'slug', 'id');
params = _.pick(params, 'category', 'slug', 'id');

if (params['category']) {
params['slug'] = params['category'] + '/' + params['slug'];
params = _.omit(params, 'category');
}

// Add author & tag
params.include = 'author,tags';

@@ -60,7 +60,7 @@ utils = {
string = unidecode(string);

// Replace URL reserved chars: `@:/?#[]!$&()*+,;=` as well as `\%<>|^~£"{}` and \`
string = string.replace(/(\s|\.|@|:|\/|\?|#|\[|\]|!|\$|&|\(|\)|\*|\+|,|;|=|\\|%|<|>|\||\^|~|"|\{|\}|`||—)/g, '-')
string = string.replace(/(\s|\.|@|:|\?|#|\[|\]|!|\$|&|\(|\)|\*|\+|,|;|=|\\|%|<|>|\||\^|~|"|\{|\}|`||—)/g, '-')
// Remove apostrophes
.replace(/'/g, '')
// Make the whole thing lowercase

1 comment on commit 9580b97

@rawsh

This comment has been minimized.

Copy link

commented on 9580b97 Sep 20, 2016

Noice, thank you very much!

Please sign in to comment.
You can’t perform that action at this time.