From 99bc0aa520abfd0ca2a4cbbdf9bc39df5fd3c773 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 20 Apr 2018 17:07:40 -0400 Subject: [PATCH] fix: redirect /foo to /foo/ during dev (close #183) --- lib/app/app.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/app/app.js b/lib/app/app.js index a46aa706..4db19c1a 100644 --- a/lib/app/app.js +++ b/lib/app/app.js @@ -63,6 +63,17 @@ export function createApp () { } }) + // redirect /foo to /foo/ + router.beforeEach((to, from, next) => { + if (!/(\/|\.html)$/.test(to.path)) { + next(Object.assign({}, to, { + path: to.path + '/' + })) + } else { + next() + } + }) + const options = {} enhanceApp({ Vue, options, router })