mirror of https://github.com/ColorlibHQ/AdminLTE
Update index.js
Improved path conversion to allow any number of subpathspull/5095/head
parent
c593a455b6
commit
b396e718aa
|
@ -1,27 +1,12 @@
|
||||||
function convertPathToHtml(path) {
|
function convertPathToHtml(path) {
|
||||||
let count = 0
|
let htmlpath = ''
|
||||||
while (path.startsWith('../')) {
|
while (path.startsWith('../')) {
|
||||||
count++
|
|
||||||
path = path.slice(3)
|
path = path.slice(3)
|
||||||
|
if (htmlpath.length < 2) htmlpath += '.'
|
||||||
|
else htmlpath += '/..'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count === 1) {
|
return htmlpath
|
||||||
return '.'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count === 2) {
|
|
||||||
return '..'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count === 3) {
|
|
||||||
return '../..'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count === 4) {
|
|
||||||
return '../../..'
|
|
||||||
}
|
|
||||||
|
|
||||||
return ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { convertPathToHtml }
|
export { convertPathToHtml }
|
||||||
|
|
Loading…
Reference in New Issue