Skip to content

Commit

Permalink
Merge pull request #5095 from claudiopatricio/patch-1
Browse files Browse the repository at this point in the history
Improved path conversion to allow any number of subpaths
  • Loading branch information
danny007in authored May 9, 2023
2 parents 1a6b7c2 + 2458b90 commit 5cdfbaf
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions src/utils/index.js
Original file line number Diff line number Diff line change
@@ -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 }

0 comments on commit 5cdfbaf

Please sign in to comment.