/opt/file
. In other words, I can only create / edit / delete folders on this path.
I want to validate that the start path is always / opt / file.
What is the best way to do this? Thanks
/opt/file
. In other words, I can only create / edit / delete folders on this path.
I want to validate that the start path is always / opt / file.
What is the best way to do this? Thanks
Since the path is a string
you can use the indexOf
in question starts with the text that was provided. It would look something like this:
...
if (path.indexOf('/opt/file') === 0) {
// Faz o que deve fazer com o arquivo
...
The
indexOf
method returns the index of the first occurrence of the value specified in searchValue within theindexOf()
object to which it was called, starting the search fromString
. Returns -1 if the value is not found.str.indexOf(searchValue[, fromIndex])
searchValue
A string representing the value to be fetched.
fromIndex
The position of the original string from which the search should begin. It can be any integer. The default value is 0. If
fromIndex
the entire string is traversed (equivalent to passing 0). IffromIndex < 0
, the method will return -1.