Uri

Utility functions related to URI paths.

Methods

static cleanFullpath(fullpath) → String

Cleans resource name (removing double slashes to avoid problems) It is slow, so use it only in changes, not in getters

Parameters
fullpath String
Returns
String

static getBasename(fullpath) → String

Returns the filename without the folder or the extension

Parameters
fullpath String
Returns
String

filename extension

static getExtension(fullpath, complexExtension) → String

Returns the filename extension from an url

Parameters
fullpath String

fullpath url or filename

complexExtension bool false

complex_extension [optional] returns the extension from the first dot, otherwise only the part from last dot.

Returns
String

filename extension

static getFilename(fullpath) → String

Returns the filename from a full path

Parameters
fullpath String
Returns
String

filename extension

static getFolder(fullpath) → String

Returns the folder from a fullpath. This includes the server address, and everything up to the first /.

Parameters
fullpath *
Returns
String

folder name

static getNoCache() → String

Returns a string to append to any url that should use the browser cache (when updating server info)

Returns
String

static getProtocol(url) → String

Returns the url protocol (http, https) or empty string if no protocol was found

Parameters
url String
Returns
String

static parseQueryString(url) → Object

Parse the parameters from a GET url.

Parameters
url String

The URL to parse, such as "http://foo.com/t.html?a=1&b=3&c=m2-m3"

Returns
Object

The map of parsed parameters, in the form {name:value}.

static removeExtension(fullpath, complexExtension) → String

Returns the url without the extension

Parameters
fullpath String

url or filename

complexExtension bool false

removes the extension from the first dot, otherwise only the part from last dot.

Returns
String

url without extension

static replaceExtension(fullpath, extension, complexExtension) → String

Replaces the extension of a filename

Parameters
fullpath String

url or filename

extension String

The new extension to add to the file name.

complexExtension bool false

If true, remove the old extension at the first dot, otherwise from the last dot.

Returns
String

url with the new extension