Browse Source

Merge pull request #5095 from claudiopatricio/patch-1

Improved path conversion to allow any number of subpaths
pull/5108/head
Daniel 2 years ago committed by GitHub
parent
commit
5cdfbaf68a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      src/utils/index.js

22
src/utils/index.js

@ -1,27 +1,11 @@
function convertPathToHtml(path) {
let count = 0
let htmlpath = ''
while (path.startsWith('../')) {
count++
path = path.slice(3)
htmlpath += htmlpath.length < 2 ? '.' : '/..'
}
if (count === 1) {
return '.'
}
if (count === 2) {
return '..'
}
if (count === 3) {
return '../..'
}
if (count === 4) {
return '../../..'
}
return ''
return htmlpath
}
export { convertPathToHtml }

Loading…
Cancel
Save