From ce99a04f2e8e95c694424fe45fb969b02192b75b Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sun, 12 Feb 2017 21:53:38 +0800 Subject: [PATCH] fix(src): get alias --- src/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 3065d1802..c6392cd77 100644 --- a/src/index.js +++ b/src/index.js @@ -50,6 +50,16 @@ render.init() let cacheRoute = null let cacheXhr = null +const getAlias = function (route) { + route = route.replace(/\/+/, '/') + + if (OPTIONS.alias[route]) { + return getAlias(OPTIONS.alias[route]) + } else { + return route + } +} + const mainRender = function (cb) { let page let route = utils.getRoute() @@ -65,7 +75,7 @@ const mainRender = function (cb) { // replace route if (OPTIONS.alias && OPTIONS.alias['/' + route]) { - route = OPTIONS.alias['/' + route] + route = getAlias('/' + route) } else { route = OPTIONS.basePath + route }