cfx
Version:
programmatically use cfx with node.js
139 lines (110 loc) • 3.72 kB
Markdown
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!-- contributed by Atul Varma [atul.com] -->
<!-- edited by Noelle Murata [fiveinchpixie.com] -->
The `url` module provides functionality for the parsing and retrieving of URLs.
<api name="URL">
<api name="URL">
The URL constructor creates an object that represents a URL, verifying that
the provided string is a valid URL in the process. Any API in the SDK which
has a URL parameter will accept `URL` objects, not raw strings, unless
otherwise noted.
source {string}
A string to be converted into a URL. If `source` is not a valid URI, this
constructor will throw an exception.
[base] {string}
An optional string used to resolve relative `source` URLs into absolute ones.
</api>
<api name="scheme">
{string}
The name of the protocol in the URL.
</api>
<api name="userPass">
{string}
The username:password part of the URL, `null` if not present.
</api>
<api name="host">
{string}
The host of the URL, `null` if not present.
</api>
<api name="port">
{integer}
The port number of the URL, `null` if none was specified.
</api>
<api name="path">
{string}
The path component of the URL.
</api>
<api name="toString">
Returns a string representation of the URL.
{string}
The URL as a string.
</api>
</api>
<api name="toFilename">
Attempts to convert the given URL to a native file path. This function will
automatically attempt to resolve non-file protocols, such as the `resource:`
protocol, to their place on the file system. An exception is raised if the URL
can't be converted; otherwise, the native file path is returned as a string.
url {string}
The URL, as a string, to be converted.
{string}
The converted native file path as a string.
</api>
<api name="fromFilename">
Converts the given native file path to a `file:` URL.
path {string}
The native file path, as a string, to be converted.
{string}
The converted URL as a string.
</api>
<api name="isValidURI">
Checks the validity of a URI. `isValidURI("http://mozilla.org")` would return `true`, whereas `isValidURI("mozilla.org")` would return `false`.
uri {string}
The URI, as a string, to be tested.
{boolean}
A boolean indicating whether or not the URI is valid.
</api>
<api name="DataURL">
<api name="DataURL">
The DataURL constructor creates an object that represents a data: URL,
verifying that the provided string is a valid data: URL in the process.
uri {string}
A string to be parsed as Data URL. If is not a valid URI, this constructor
will throw an exception.
</api>
<api name="mimeType">
{string}
The MIME type of the data. By default is an empty string.
</api>
<api name="parameters">
{object}
An hashmap that contains the parameters of the Data URL. By default is
an empty object.
</api>
<api name="base64">
{boolean}
Defines the encoding for the value in `data` property.
</api>
<api name="data">
{string}
The string that contains the data in the Data URL.
If the `uri` given to the constructor contains `base64` parameter, this string is decoded.
</api>
<api name="toString">
Returns a string representation of the Data URL.
If `base64` is `true`, the `data` property is encoded using base-64 encoding.
{string}
The URL as a string.
</api>
</api>