Better document URLs

This commit is contained in:
Jori Lallo
2017-07-03 13:17:29 -05:00
parent 91e09e3853
commit 29037251c0
3 changed files with 28 additions and 7 deletions

View File

@@ -9,7 +9,7 @@ import { convertToMarkdown } from '../../frontend/utils/markdown';
import { truncateMarkdown } from '../utils/truncate';
import Revision from './Revision';
const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{10,15})$/;
const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z]{10,15})$/;
slug.defaults.mode = 'rfc3986';
const slugify = text =>
@@ -100,7 +100,7 @@ const Document = sequelize.define(
instanceMethods: {
getUrl() {
const slugifiedTitle = slugify(this.title);
return `/d/${slugifiedTitle}-${this.urlId}`;
return `/${slugifiedTitle}-${this.urlId}`;
},
toJSON() {
// Warning: only use for new documents as order of children is