Misc. (#281)
* Logger * etag cache fix * xml refactor * whitespace * NodePathUtils * Http2
This commit is contained in:
1 parent
44ee6681c5
commit
f3aeb58b38
13 files changed
+104
-75
No files matched your search
@@ -0,0 +1,35 @@
|
||||
namespace NodePathUtils
|
||||
|
||||
function FindNodeFromPath(root as object, path as string) as object
|
||||
node = root
|
||||
|
||||
if path.StartsWith("/")
|
||||
node = node.getScene()
|
||||
path = path.Mid(1)
|
||||
end if
|
||||
|
||||
pathParts = path.Tokenize("/")
|
||||
|
||||
for i = 0 to pathParts.Count() - 1
|
||||
if node = invalid
|
||||
return invalid
|
||||
end if
|
||||
if pathParts[i] = "."
|
||||
continue for
|
||||
end if
|
||||
if pathParts[i] = ".."
|
||||
node = node.getParent()
|
||||
continue for
|
||||
end if
|
||||
node = node.findNode(pathParts[i])
|
||||
end for
|
||||
|
||||
if root.isSameNode(node)
|
||||
' if a node is referencing itself, it's probably a mistake
|
||||
return invalid
|
||||
end if
|
||||
|
||||
return node
|
||||
end function
|
||||
|
||||
end namespace
|
||||
Reference in new issue
Block a user