From 29037251c0b4b229f8fe78450ea2872eff71b574 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 3 Jul 2017 13:17:29 -0500 Subject: [PATCH] Better document URLs --- frontend/index.js | 20 ++++++++++++++++++-- frontend/scenes/Document/Document.js | 11 ++++++++--- server/models/Document.js | 4 ++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/frontend/index.js b/frontend/index.js index 7fe3a575c..539aa4fcc 100644 --- a/frontend/index.js +++ b/frontend/index.js @@ -87,6 +87,9 @@ const KeyboardShortcuts = () => ( const Api = () => ; const DocumentNew = () => ; const DocumentNewChild = () => ; +const RedirectDocument = ({ match }: { match: Object }) => ( + +); render(
@@ -106,9 +109,22 @@ render( - + + - + { diff --git a/server/models/Document.js b/server/models/Document.js index f0f5e9001..45df9bd0e 100644 --- a/server/models/Document.js +++ b/server/models/Document.js @@ -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