URLUtils Class
Utilities that assist with parsing load items, and determining file types, etc.
Item Index
Methods
- buildURI static
- formatQueryString static
- isCrossDomain static
- isLocal static
- parseURI static
Properties
- ABSOLUTE_PATH static
- EXTENSION_PATT static
- RELATIVE_PATH static
Methods
buildURI
-
src
-
[data]
A utility method that builds a file path using a source and a data object, and formats it into a new path.
Parameters:
Returns:
A formatted string that contains the path and the supplied parameters.
formatQueryString
-
data
-
[query]
Formats an object into a query string for either a POST or GET request.
isCrossDomain
-
item
Returns:
If the load item is loading from a different domain than the current location.
isLocal
-
item
Returns:
If the load item is loading from the "file:" protocol. Assume that the host must be local as well.
parseURI
-
path
Parse a file path to determine the information we need to work with it. Currently, PreloadJS needs to know:
- If the path is absolute. Absolute paths start with a protocol (such as
http://
,file://
, or//networkPath
) - If the path is relative. Relative paths start with
../
or/path
(or similar) - The file extension. This is determined by the filename with an extension. Query strings are dropped, and
the file path is expected to follow the format
name.ext
.
Parameters:
-
path
String
Returns:
An Object with an absolute
and relative
Boolean values,
the pieces of the path (protocol, hostname, port, pathname, search, hash, host)
as well as an optional 'extension` property, which is the lowercase extension.
Properties
EXTENSION_PATT
RegExp
static
The Regular Expression used to test file URLS for an extension. Note that URIs must already have the query string removed.