Skip to content

Commit

Permalink
Update Files.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Feb 26, 2024
1 parent 120dd45 commit 9d36959
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/components/Files.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@ function parseFileStructure(ascii:string, indent:number = 2) {
const stack = [root]
for (const line of lines) {
const depth = line.search(/\S/)/indent
const depth = line.search(/\S/) / indent
const name = line.trim()
const parent:{[name:string]:any} = stack[depth]
const isDir = name.startsWith('/')
if (name.includes('.')) {
parent._.push(name)
} else {
const newObj = { _: [] }
const dir = name.substring(1)
parent[dir] = newObj
if (isDir) {
const dirName = name.substring(1)
const dirContents = { _: [] }
parent[dirName] = dirContents
stack.length = depth + 1
stack.push(newObj)
stack.push(dirContents)
} else {
parent._.push(name)
}
}
return root
Expand Down

0 comments on commit 9d36959

Please sign in to comment.