Methods
(static) csriURLToURI(url) → {string}
Converts specified URI to an actual URI if it's a "csri:" URL
(Client Side Resource Identifier, an URL form common to
XMLEditor and XXE server of an URI managed by
client-code); returns specified URI as is otherwise.
"csri:" URL examples:
csri://(file)@no-authority/tmp/doc.xml csri://(file)@myserver/share/docs/doc.xml csri://(urn)@opaque-uri/ietf:rfc:2648 csri://(https)@www.xmlmind.com:80/xmleditor/index.html csri://(ftp)foo:bar@xmlmind.com/xmleditor/index.html
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | an URL, possibly a "csri:" one. |
- Source:
Returns:
corresponding URI.
- Type
- string
(static) isAbsolutePath(path, pathSepar) → {boolean}
Tests whether specified path is absolute or relative.
On Windows, a drive relative path like "\foo\bar" is considered to be relative. Only "C:\foo\bar" or "\\my-server\foo\bar" are considered to be absolute.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | relative or absolute path. |
pathSepar |
string | the character used to separate path segments (that is, '/' for URIs). |
- Source:
Returns:
true if absolute;
false if relative.
- Type
- boolean
(static) isAbsoluteURI(uri) → {boolean}
Tests whether specified URI is an absolute hierarchical URI.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | a relative or absolute, valid URI. |
- Source:
Returns:
true if it's an absolute
hierarchical URI; false otherwise.
- Type
- boolean
(static) joinURI()
Join specified URI components and return resulting URI.
Specified URI components are joined as is, that is,
without first encoding them using encodeURIComponent.
- Source:
(static) normalizeFileURI()
Returns specified absolute URI after normalizing its authority
if it's a "file:" URI. Otherwise returns specified URI as is.
- Source:
(static) normalizePath(path, pathSepar) → {string}
Returns specified relative or absolute path after normalizing it,
that is, after removing ".", ".." and duplicate path separators from it.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | relative or absolute path. |
pathSepar |
string | the character used to separate path segments (that is, '/' for URIs). |
- Source:
Returns:
normalized path or original path if it is not possible
to normalize it (examples: "../../foo/bar", "a/ /b/c").
- Type
- string
(static) pathBasename(path, pathSepar) → {string}
Returns the base name of specified path. To make it simple, the
substring after last '/'.
Examples:
- Returns the empty string for "/".
- Returns "foo" for "foo".
- Returns "bar" for "/foo/bar".
- Returns "bar" for "/foo/bar/".
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | relative or absolute path |
pathSepar |
string | the character used to separate path segments (that is, '/' for URIs) |
- Source:
Returns:
base name of specified path
- Type
- string
(static) pathExtension(path, pathSepar) → {string}
Returns the extension of specified path. To make it simple, the
substring after last '.', not including last '.'.
- Returns
nullfor "/tmp/test". - Returns the empty string for "/tmp/test.".
- Returns
nullfor "~/.profile". - Returns "gz" for "/tmp/test.tar.gz".
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | relative or absolute path possibly having an extension |
pathSepar |
string | the character used to separate path segments (that is, '/' for URIs) |
- Source:
Returns:
extension if any;
null otherwise
- Type
- string
(static) pathParent(path, pathSepar, trailingSepar) → {string}
Returns the parent of specified path. To make it simple,
the substring before last '/'.
Examples:
- Returns
nullfor "/". - Returns
nullfor "foo". - Returns "/" for "/foo".
- Returns "/foo" (or "/foo/") for "/foo/bar".
- Returns "/foo" (or "/foo/") for "/foo/bar/".
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | relative or absolute path |
pathSepar |
string | the character used to separate path segments (that is, '/' for URIs) |
trailingSepar |
string | if true,
returned path ends with a trailing pathSepar character |
- Source:
Returns:
parent of specified path or
null for pathSepar or if specified path
does not contain the pathSepar character
- Type
- string
(static) pathToFileURI(path, pathSeparopt) → {string}
Convert specified path to a "file:" URI.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
path |
string | relative or absolute path. | ||
pathSepar |
string |
<optional> |
FILE_PATH_SEPARATOR | pathSepar - the character used to separate file path segments (that is, '\' on Windows). |
- Source:
Returns:
corresponding relative or absolute "file:" URI.
Note that if
path is relative, this URI will have no
"file:" scheme (e.g. returns "tmp/my%20doc.xml" for "tmp\\my doc.xml");
- Type
- string
(static) relativizePath(path, basePath, pathSepar) → {string}
Returns specified path after making it relative to the other path
(when this is possible).
IMPORTANT: a directory path is expected to end
with pathSepar.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | an absolute path. |
basePath |
string | another absolute path which is used as a base. |
pathSepar |
string | the character used to separate path segments (that is, '/' for URIs) |
- Source:
Returns:
the relative path when possible;
specified path as is otherwise (Windows example: when specified paths
don't have the same drive.
- Type
- string
(static) relativizeURI(uri, baseURI) → {string}
Returns specified URI after making it relative to the other URI
(when this is possible).
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | an absolute, valid URI. |
baseURI |
string | another absolute, valid URI which is used as a base URI. |
- Source:
Returns:
the relative URI when possible;
specified uri as is otherwise (for example, when specified URIs
don't have the same scheme or authority).
- Type
- string
(static) resolvePath(path, basePath, pathSepar) → {string}
Resolves specified path against specified base.
IMPORTANT: a directory path is expected to end
with pathSepar.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | relative or absolute path. |
basePath |
string | relative or absolute path. |
pathSepar |
string | the character used to separate path segments (that is, '/' for URIs). |
- Source:
Returns:
resolved path.
- Type
- string
(static) resolveURI(uri, baseURI) → {string}
Returns specified relative URI after resolving it against the other URI.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | a relative or absolute, valid URI. |
baseURI |
string | an absolute, valid URI which is used as a base URI. |
- Source:
Returns:
the resolved URI when possible;
specified uri as is otherwise (for example, when specified URI
is already absolute).
- Type
- string
(static) splitURI(uri) → {array}
Splits specified URI into its components:
scheme, authority, path, query, fragment.
Note that returned URI components are NOT decoded using
decodeURIComponent.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | a relative or absolute, valid URI. |
- Source:
Returns:
an array containing scheme, authority, path, query,
fragment, each of this component possibly being
null or
just the empty string.
- Type
- array
(static) uriBasename(uri) → {string}
Returns the basename, if any, of specified URI.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | a relative or absolute, valid URI. |
- Source:
- See:
-
- URLUtil#uriRawBasename
Returns:
the basename of specified URI decoded using
decodeURIComponent if any;
null otherwise.
- Type
- string
(static) uriExtension(uri) → {string}
Returns the file extension, if any, of specified URI.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | a relative or absolute, valid URI. |
- Source:
Returns:
the file extension of specified URI if any;
null otherwise.
- Type
- string
(static) uriParent(uri, trailingSeparopt) → {string}
Returns the parent, if any, of specified URI.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
uri |
string | a relative or absolute, valid URI. | ||
trailingSepar |
string |
<optional> |
true | trailingSepar - if
true, returned URI has a path which ends with
a trailing '/' character. |
- Source:
Returns:
the parent of specified URI if any;
null otherwise.
- Type
- string
(static) uriRawBasename(uri) → {string}
Returns the basename, if any, of specified URI.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | a relative or absolute, valid URI. |
- Source:
- See:
-
- URLUtil#uriBasename
Returns:
the basename of specified URI if any;
null otherwise.
- Type
- string
(static) uriSetBasename(uri, basename) → {string}
Changes the basename of specified URI.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | a relative or absolute, valid URI. |
basename |
string | the new basename to be encoded using
encodeURIComponent. |
- Source:
- See:
-
- URLUtil#uriSetRawBasename
Returns:
modified URI;
null if specified
URI has no path.
- Type
- string
(static) uriSetRawBasename(uri, basename) → {string}
Changes the basename of specified URI.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | a relative or absolute, valid URI. |
basename |
string | the new basename. |
- Source:
- See:
-
- URLUtil#uriSetBasename
Returns:
modified URI;
null if specified
URI has no path.
- Type
- string
(static) uriToFilePath(uri, pathSeparopt) → {string}
Returns the file path corresponding to specified absolute "file:" URI.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
uri |
string | an absolute, valid, "file:" URI. | ||
pathSepar |
string |
<optional> |
FILE_PATH_SEPARATOR | pathSepar - the character used to separate file path segments (that is, '\' on Windows). |
- Source:
Returns:
corresponding absolute file path when possible,
null otherwise.
- Type
- string