aboutsummaryrefslogtreecommitdiff
path: root/tools/addon-sdk-1.5/packages/api-utils/docs/url.md
blob: 29747971a038c89ecdf4ff7a3aeac2c2ef43067e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!-- 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@mozilla.com]  -->
<!-- edited by Noelle Murata [fiveinchpixie@gmail.com]  -->


The `url` module provides functionality for the parsing and retrieving of URLs.

<api name="URL">
@class
<api name="URL">
@constructor
  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.

@param source {string}
  A string to be converted into a URL. If `source` is not a valid URI, this
  constructor will throw an exception.

@param [base] {string}
  An optional string used to resolve relative `source` URLs into absolute ones.
</api>

<api name="scheme">
@property {string}
  The name of the protocol in the URL.
</api>

<api name="userPass">
@property {string}
  The username:password part of the URL, `null` if not present.
</api>

<api name="host">
@property {string}
  The host of the URL, `null` if not present.
</api>

<api name="port">
@property {integer}
  The port number of the URL, `null` if none was specified.
</api>

<api name="path">
@property {string}
  The path component of the URL.
</api>

<api name="toString">
@method
  Returns a string representation of the URL.
@returns {string}
  The URL as a string.
</api>
</api>

<api name="toFilename">
@function
  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.

@param url {string}
  The URL, as a string, to be converted.

@returns {string}
  The converted native file path as a string.
</api>

<api name="fromFilename">
@function
  Converts the given native file path to a `file:` URL.

@param path {string}
  The native file path, as a string, to be converted.

@returns {string}
  The converted URL as a string.
</api>