$$pathjoin
Joins paths segments into a single path string (removing duplicate separators and resolving relative paths; ../.)
Usage​
{
"$$pathjoin": /* Array of path segments */,
"type": "POSIX" /* or WINDOWS / URL */
}
"$$pathjoin([type]):{input}"
note
Concrete values in the usage example are default values.
Returns​
string
Arguments​
| Argument | Type | Values | Required / Default Value | Description |
|---|---|---|---|---|
| Input | array | Yes | Array of path segments | |
type | enum | POSIX/ WINDOWS/URL | POSIX | Path separator type (URL will url-encode the segments and prefix output with /) |
Examples​
Input
Definition
Output
[
"dir1",
"dir2",
"file.json"
]
{
"$$pathjoin": "$"
}
"dir1/dir2/file.json"
[
"dir1/",
"/dir2",
"file.json"
]
{
"$$pathjoin": "$"
}
"dir1/dir2/file.json"
[
"dir1",
"dir2",
"file.json"
]
{
"$$pathjoin": "$",
"type": "WINDOWS"
}
"dir1\\dir2\\file.json"
[
"dir1\\",
"\\dir2",
"file.json"
]
{
"$$pathjoin": "$",
"type": "WINDOWS"
}
"dir1\\dir2\\file.json"
[
"dir1",
"dir?",
"/file.json"
]
{
"$$pathjoin": "$",
"type": "URL"
}
"/dir1/dir%3F/%2Ffile.json"
[
"dir1",
"dir2",
"..",
"file.json"
]
{
"$$pathjoin": "$"
}
"dir1/file.json"
[
"dir1",
"dir2//",
"..",
"/file.json"
]
{
"$$pathjoin": "$"
}
"dir1/file.json"
[
"dir1.",
"dir2/..",
"..",
"/..file.json"
]
"$$pathjoin:$"
"..file.json"
[
"dir1",
"..dir2",
".",
"/.file.json"
]
"$$pathjoin:$"
"dir1/..dir2/.file.json"
[
"dir1.",
"././.",
"dir2.."
]
"$$pathjoin:$"
"dir1./dir2.."
[
"dir1",
"dir2",
".."
]
"$$pathjoin:$"
"dir1"
[
"a",
"b",
"c",
"..",
"..",
"..",
"..",
".htaccess"
]
"$$pathjoin:$"
null