netwerk/base/public/nsIURL.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsIURI.idl"
michael@0 7
michael@0 8 /**
michael@0 9 * The nsIURL interface provides convenience methods that further
michael@0 10 * break down the path portion of nsIURI:
michael@0 11 *
michael@0 12 * http://host/directory/fileBaseName.fileExtension?query
michael@0 13 * http://host/directory/fileBaseName.fileExtension#ref
michael@0 14 * \ \ /
michael@0 15 * \ -----------------------
michael@0 16 * \ | /
michael@0 17 * \ fileName /
michael@0 18 * ----------------------------
michael@0 19 * |
michael@0 20 * filePath
michael@0 21 */
michael@0 22 [scriptable, uuid(1419aa16-f134-4154-9886-00c7c5147a13)]
michael@0 23 interface nsIURL : nsIURI
michael@0 24 {
michael@0 25 /*************************************************************************
michael@0 26 * The URL path is broken down into the following principal components:
michael@0 27 */
michael@0 28
michael@0 29 /**
michael@0 30 * Returns a path including the directory and file portions of a
michael@0 31 * URL. For example, the filePath of "http://host/foo/bar.html#baz"
michael@0 32 * is "/foo/bar.html".
michael@0 33 *
michael@0 34 * Some characters may be escaped.
michael@0 35 */
michael@0 36 attribute AUTF8String filePath;
michael@0 37
michael@0 38 /**
michael@0 39 * Returns the query portion (the part after the "?") of the URL.
michael@0 40 * If there isn't one, an empty string is returned.
michael@0 41 *
michael@0 42 * Some characters may be escaped.
michael@0 43 */
michael@0 44 attribute AUTF8String query;
michael@0 45
michael@0 46
michael@0 47 /*************************************************************************
michael@0 48 * The URL filepath is broken down into the following sub-components:
michael@0 49 */
michael@0 50
michael@0 51 /**
michael@0 52 * Returns the directory portion of a URL. If the URL denotes a path to a
michael@0 53 * directory and not a file, e.g. http://host/foo/bar/, then the Directory
michael@0 54 * attribute accesses the complete /foo/bar/ portion, and the FileName is
michael@0 55 * the empty string. If the trailing slash is omitted, then the Directory
michael@0 56 * is /foo/ and the file is bar (i.e. this is a syntactic, not a semantic
michael@0 57 * breakdown of the Path). And hence don't rely on this for something to
michael@0 58 * be a definitely be a file. But you can get just the leading directory
michael@0 59 * portion for sure.
michael@0 60 *
michael@0 61 * Some characters may be escaped.
michael@0 62 */
michael@0 63 attribute AUTF8String directory;
michael@0 64
michael@0 65 /**
michael@0 66 * Returns the file name portion of a URL. If the URL denotes a path to a
michael@0 67 * directory and not a file, e.g. http://host/foo/bar/, then the Directory
michael@0 68 * attribute accesses the complete /foo/bar/ portion, and the FileName is
michael@0 69 * the empty string. Note that this is purely based on searching for the
michael@0 70 * last trailing slash. And hence don't rely on this to be a definite file.
michael@0 71 *
michael@0 72 * Some characters may be escaped.
michael@0 73 */
michael@0 74 attribute AUTF8String fileName;
michael@0 75
michael@0 76
michael@0 77 /*************************************************************************
michael@0 78 * The URL filename is broken down even further:
michael@0 79 */
michael@0 80
michael@0 81 /**
michael@0 82 * Returns the file basename portion of a filename in a url.
michael@0 83 *
michael@0 84 * Some characters may be escaped.
michael@0 85 */
michael@0 86 attribute AUTF8String fileBaseName;
michael@0 87
michael@0 88 /**
michael@0 89 * Returns the file extension portion of a filename in a url. If a file
michael@0 90 * extension does not exist, the empty string is returned.
michael@0 91 *
michael@0 92 * Some characters may be escaped.
michael@0 93 */
michael@0 94 attribute AUTF8String fileExtension;
michael@0 95
michael@0 96 /**
michael@0 97 * This method takes a uri and compares the two. The common uri portion
michael@0 98 * is returned as a string. The minimum common uri portion is the
michael@0 99 * protocol, and any of these if present: login, password, host and port
michael@0 100 * If no commonality is found, "" is returned. If they are identical, the
michael@0 101 * whole path with file/ref/etc. is returned. For file uris, it is
michael@0 102 * expected that the common spec would be at least "file:///" since '/' is
michael@0 103 * a shared common root.
michael@0 104 *
michael@0 105 * Examples:
michael@0 106 * this.spec aURIToCompare.spec result
michael@0 107 * 1) http://mozilla.org/ http://www.mozilla.org/ ""
michael@0 108 * 2) http://foo.com/bar/ ftp://foo.com/bar/ ""
michael@0 109 * 3) http://foo.com:8080/ http://foo.com/bar/ ""
michael@0 110 * 4) ftp://user@foo.com/ ftp://user:pw@foo.com/ ""
michael@0 111 * 5) ftp://foo.com/bar/ ftp://foo.com/bar ftp://foo.com/
michael@0 112 * 6) ftp://foo.com/bar/ ftp://foo.com/bar/b.html ftp://foo.com/bar/
michael@0 113 * 7) http://foo.com/a.htm#i http://foo.com/b.htm http://foo.com/
michael@0 114 * 8) ftp://foo.com/c.htm#i ftp://foo.com/c.htm ftp://foo.com/c.htm
michael@0 115 * 9) file:///a/b/c.html file:///d/e/c.html file:///
michael@0 116 */
michael@0 117 AUTF8String getCommonBaseSpec(in nsIURI aURIToCompare);
michael@0 118
michael@0 119 /**
michael@0 120 * This method tries to create a string which specifies the location of the
michael@0 121 * argument relative to |this|. If the argument and |this| are equal, the
michael@0 122 * method returns "". If any of the URIs' scheme, host, userpass, or port
michael@0 123 * don't match, the method returns the full spec of the argument.
michael@0 124 *
michael@0 125 * Examples:
michael@0 126 * this.spec aURIToCompare.spec result
michael@0 127 * 1) http://mozilla.org/ http://www.mozilla.org/ http://www.mozilla.org/
michael@0 128 * 2) http://mozilla.org/ http://www.mozilla.org http://www.mozilla.org/
michael@0 129 * 3) http://foo.com/bar/ http://foo.com:80/bar/ ""
michael@0 130 * 4) http://foo.com/ http://foo.com/a.htm#b a.html#b
michael@0 131 * 5) http://foo.com/a/b/ http://foo.com/c ../../c
michael@0 132 */
michael@0 133 AUTF8String getRelativeSpec(in nsIURI aURIToCompare);
michael@0 134
michael@0 135 };

mercurial