提交 d1e4cc34 编写于 作者: D DCloud_LXH

fix: 文档重定向的时候,转小写

上级 fb7d85b6
...@@ -108,12 +108,18 @@ const routerMap = { ...@@ -108,12 +108,18 @@ const routerMap = {
'/uni-app-x/': 'https://doc.dcloud.net.cn/uni-app-x/' '/uni-app-x/': 'https://doc.dcloud.net.cn/uni-app-x/'
} }
function fileNameToLowerCase (path) {
return path.replace(/\/[\w-]+\.(html|md)/, ($1) => {
return $1.toLocaleLowerCase()
})
}
export default ({ fullPath, path, hash }) => { export default ({ fullPath, path, hash }) => {
fullPath = decodeURIComponent(fullPath) fullPath = decodeURIComponent(fullPath)
const matchFullPath = routerMap[fullPath.replace('?id=', '#').replace('.html', '')]; const matchFullPath = routerMap[fullPath.replace('?id=', '#').replace('.html', '')];
if (matchFullPath) { if (matchFullPath) {
return { return {
path: matchFullPath, path: fileNameToLowerCase(matchFullPath),
replace: true replace: true
} }
} }
...@@ -121,7 +127,7 @@ export default ({ fullPath, path, hash }) => { ...@@ -121,7 +127,7 @@ export default ({ fullPath, path, hash }) => {
const matchPath = routerMap[path] || routerMap[path.replace('.html', '')] const matchPath = routerMap[path] || routerMap[path.replace('.html', '')]
if (matchPath) { if (matchPath) {
return { return {
path: matchPath, path: fileNameToLowerCase(matchPath),
hash, hash,
replace: true replace: true
} }
...@@ -129,7 +135,7 @@ export default ({ fullPath, path, hash }) => { ...@@ -129,7 +135,7 @@ export default ({ fullPath, path, hash }) => {
if (path.indexOf('/app-') === 0 || path.indexOf('/android-') === 0 || path.indexOf('/ios-') === 0) { if (path.indexOf('/app-') === 0 || path.indexOf('/android-') === 0 || path.indexOf('/ios-') === 0) {
return { return {
path: `/tutorial${path}`, path: `/tutorial${fileNameToLowerCase(path)}`,
hash, hash,
replace: true replace: true
} }
...@@ -140,7 +146,8 @@ export default ({ fullPath, path, hash }) => { ...@@ -140,7 +146,8 @@ export default ({ fullPath, path, hash }) => {
routerMapKeys.forEach(key => { routerMapKeys.forEach(key => {
if (path.indexOf(key) === 0 && routerMap[key].indexOf(key) !== 0 && routerMap[key] !== path) { if (path.indexOf(key) === 0 && routerMap[key].indexOf(key) !== 0 && routerMap[key] !== path) {
return returnPathConfig = { return returnPathConfig = {
path: path.replace(key, routerMap[key]), // fixed: 文件名转为小写
path: fileNameToLowerCase(path.replace(key, routerMap[key])),
hash, hash,
replace: true replace: true
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册