fcf.normalizePath() function
Package: fcf-framework-core
File: fcf-framework-core:fcf.js
Available from version: 2.0.2
Normalizes the resource path (File path/HTTP/HTTPS).
Removes "./" paths and offsets "../" within the package's relative path. Changes double // to single / and replaces \ with /
Arguments
- Source path
- If it is true , then the path contains the file system address or FCF address.
If it is
Result
- Soucre path
Example: Function application
{
let result = fcf.normalizePath("package-name:dir///file.txt");
console.log(result)
}
{
let result = fcf.normalizePath("package-name:dir/./file.txt");
console.log(result)
}
{
let result = fcf.normalizePath("package-name:dir/../../file.txt");
console.log(result)
}
{
let result = fcf.normalizePath("http://domain/dir/../../file.txt", false);
console.log(result)
}
{
let result = fcf.normalizePath("C:\\/dir/../../dir2\\file.txt", true);
console.log(result)
}
Output:
package-name:dir/file.txt
package-name:dir/file.txt
package-name:file.txt
http://domain/file.txt
C:\dir2/file.txt