FCF 2.0 development in progress...
> > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

fcf.normalizePath() function

string fcf.normalizePath(string a_path, boolean a_isServerPath = fcf.isServer())

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

string a_path
- Source path

boolean a_isServerPath = fcf.isServer()
- If it is true, then the path contains the file system address or FCF address.

If it is false, the path contains the WEB (HTTP/HTTPS) address or FCF address

Result
string
- 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