From 29037251c0b4b229f8fe78450ea2872eff71b574 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 3 Jul 2017 13:17:29 -0500 Subject: [PATCH 1/3] 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 From f65a5bcca2fddb8d23851494697a5ae289992ab5 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Tue, 4 Jul 2017 12:03:41 -0500 Subject: [PATCH 2/3] Swapped document urls to have `/doc` prefix --- frontend/index.js | 6 +++--- server/models/Document.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/index.js b/frontend/index.js index 539aa4fcc..160ef99d1 100644 --- a/frontend/index.js +++ b/frontend/index.js @@ -88,7 +88,7 @@ const Api = () => ; const DocumentNew = () => ; const DocumentNewChild = () => ; const RedirectDocument = ({ match }: { match: Object }) => ( - + ); render( @@ -116,13 +116,13 @@ render( /> Date: Tue, 4 Jul 2017 20:18:14 -0700 Subject: [PATCH 3/3] Updated Document scene to use new url --- frontend/scenes/Document/Document.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/scenes/Document/Document.js b/frontend/scenes/Document/Document.js index c7cf6fa21..f3cfa06c1 100644 --- a/frontend/scenes/Document/Document.js +++ b/frontend/scenes/Document/Document.js @@ -79,7 +79,7 @@ type Props = { get document() { return this.props.documents.getByUrl( - `/${this.props.match.params.documentSlug}` + `/doc/${this.props.match.params.documentSlug}` ); }