OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 /* ***** BEGIN LICENSE BLOCK ***** |
| 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 4 * |
| 5 * The contents of this file are subject to the Mozilla Public License Version |
| 6 * 1.1 (the "License"); you may not use this file except in compliance with |
| 7 * the License. You may obtain a copy of the License at |
| 8 * http://www.mozilla.org/MPL/ |
| 9 * |
| 10 * Software distributed under the License is distributed on an "AS IS" basis, |
| 11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 12 * for the specific language governing rights and limitations under the |
| 13 * License. |
| 14 * |
| 15 * The Original Code is mozilla.org code. |
| 16 * |
| 17 * The Initial Developer of the Original Code is |
| 18 * Netscape Communications Corporation. |
| 19 * Portions created by the Initial Developer are Copyright (C) 1998 |
| 20 * the Initial Developer. All Rights Reserved. |
| 21 * |
| 22 * Contributor(s): |
| 23 * Gagan Saksena <gagan@netscape.com> (original author) |
| 24 * Darin Fisher <darin@netscape.com> |
| 25 * |
| 26 * Alternatively, the contents of this file may be used under the terms of |
| 27 * either the GNU General Public License Version 2 or later (the "GPL"), or |
| 28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
| 29 * in which case the provisions of the GPL or the LGPL are applicable instead |
| 30 * of those above. If you wish to allow use of your version of this file only |
| 31 * under the terms of either the GPL or the LGPL, and not to allow others to |
| 32 * use your version of this file under the terms of the MPL, indicate your |
| 33 * decision by deleting the provisions above and replace them with the notice |
| 34 * and other provisions required by the GPL or the LGPL. If you do not delete |
| 35 * the provisions above, a recipient may use your version of this file under |
| 36 * the terms of any one of the MPL, the GPL or the LGPL. |
| 37 * |
| 38 * ***** END LICENSE BLOCK ***** */ |
| 39 |
| 40 #include "nsIURI.idl" |
| 41 |
| 42 /** |
| 43 * The nsIURL interface provides convenience methods that further |
| 44 * break down the path portion of nsIURI: |
| 45 * |
| 46 * http://directory/fileBaseName.fileExtension?query |
| 47 * http://directory/fileBaseName.fileExtension#ref |
| 48 * http://directory/fileBaseName.fileExtension;param |
| 49 * \ \ / |
| 50 * \ ----------------------- |
| 51 * \ | / |
| 52 * \ fileName / |
| 53 * ---------------------------- |
| 54 * | |
| 55 * filePath |
| 56 * |
| 57 * @status FROZEN |
| 58 */ |
| 59 [scriptable, uuid(d6116970-8034-11d3-9399-00104ba0fd40)] |
| 60 interface nsIURL : nsIURI |
| 61 { |
| 62 /************************************************************************* |
| 63 * The URL path is broken down into the following principal components: |
| 64 */ |
| 65 |
| 66 /** |
| 67 * Returns a path including the directory and file portions of a |
| 68 * URL. For example, the filePath of "http://foo/bar.html#baz" is |
| 69 * "/foo/bar.html". |
| 70 * |
| 71 * Some characters may be escaped. |
| 72 */ |
| 73 attribute AUTF8String filePath; |
| 74 |
| 75 /** |
| 76 * Returns the parameters specified after the ; in the URL. |
| 77 * |
| 78 * Some characters may be escaped. |
| 79 */ |
| 80 attribute AUTF8String param; |
| 81 |
| 82 /** |
| 83 * Returns the query portion (the part after the "?") of the URL. |
| 84 * If there isn't one, an empty string is returned. |
| 85 * |
| 86 * Some characters may be escaped. |
| 87 */ |
| 88 attribute AUTF8String query; |
| 89 |
| 90 /** |
| 91 * Returns the reference portion (the part after the "#") of the URL. |
| 92 * If there isn't one, an empty string is returned. |
| 93 * |
| 94 * Some characters may be escaped. |
| 95 */ |
| 96 attribute AUTF8String ref; |
| 97 |
| 98 |
| 99 /************************************************************************* |
| 100 * The URL filepath is broken down into the following sub-components: |
| 101 */ |
| 102 |
| 103 /** |
| 104 * Returns the directory portion of a URL. |
| 105 * If the URL denotes a path to a directory and not a file, |
| 106 * e.g. http://foo/bar/, then the Directory attribute accesses |
| 107 * the complete /foo/bar/ portion, and the FileName is the |
| 108 * empty string. If the trailing slash is omitted, then the |
| 109 * Directory is /foo/ and the file is bar (i.e. this is a |
| 110 * syntactic, not a semantic breakdown of the Path). |
| 111 * And hence dont rely on this for something to be a definitely |
| 112 * be a file. But you can get just the leading directory portion |
| 113 * for sure. |
| 114 * |
| 115 * Some characters may be escaped. |
| 116 */ |
| 117 attribute AUTF8String directory; |
| 118 |
| 119 /** |
| 120 * Returns the file name portion of a URL. |
| 121 * If the URL denotes a path to a directory and not a file, |
| 122 * e.g. http://foo/bar/, then the Directory attribute accesses |
| 123 * the complete /foo/bar/ portion, and the FileName is the |
| 124 * empty string. Note that this is purely based on searching |
| 125 * for the last trailing slash. And hence dont rely on this to |
| 126 * be a definite file. |
| 127 * |
| 128 * Some characters may be escaped. |
| 129 */ |
| 130 attribute AUTF8String fileName; |
| 131 |
| 132 |
| 133 /************************************************************************* |
| 134 * The URL filename is broken down even further: |
| 135 */ |
| 136 |
| 137 /** |
| 138 * Returns the file basename portion of a filename in a url. |
| 139 * |
| 140 * Some characters may be escaped. |
| 141 */ |
| 142 attribute AUTF8String fileBaseName; |
| 143 |
| 144 /** |
| 145 * Returns the file extension portion of a filename in a url. If a file |
| 146 * extension does not exist, the empty string is returned. |
| 147 * |
| 148 * Some characters may be escaped. |
| 149 */ |
| 150 attribute AUTF8String fileExtension; |
| 151 |
| 152 /** |
| 153 * This method takes a uri and compares the two. The common uri portion |
| 154 * is returned as a string. The minimum common uri portion is the |
| 155 * protocol, and any of these if present: login, password, host and port |
| 156 * If no commonality is found, "" is returned. If they are identical, the |
| 157 * whole path with file/ref/etc. is returned. For file uris, it is |
| 158 * expected that the common spec would be at least "file:///" since '/' is |
| 159 * a shared common root. |
| 160 * |
| 161 * Examples: |
| 162 * this.spec aURIToCompare.spec result |
| 163 * 1) http://mozilla.org/ http://www.mozilla.org/ "" |
| 164 * 2) http://foo.com/bar/ ftp://foo.com/bar/ "" |
| 165 * 3) http://foo.com:8080/ http://foo.com/bar/ "" |
| 166 * 4) ftp://user@foo.com/ ftp://user:pw@foo.com/ "" |
| 167 * 5) ftp://foo.com/bar/ ftp://foo.com/bar ftp://foo.com/ |
| 168 * 6) ftp://foo.com/bar/ ftp://foo.com/bar/b.html ftp://foo.com/bar/ |
| 169 * 7) http://foo.com/a.htm#i http://foo.com/b.htm http://foo.com/ |
| 170 * 8) ftp://foo.com/c.htm#i ftp://foo.com/c.htm ftp://foo.com/c.htm |
| 171 * 9) file:///a/b/c.html file:///d/e/c.html file:/// |
| 172 */ |
| 173 AUTF8String getCommonBaseSpec(in nsIURI aURIToCompare); |
| 174 |
| 175 /** |
| 176 * This method takes a uri and returns a substring of this if it can be |
| 177 * made relative to the uri passed in. If no commonality is found, the |
| 178 * entire uri spec is returned. If they are identical, "" is returned. |
| 179 * Filename, query, etc are always returned except when uris are identical. |
| 180 */ |
| 181 AUTF8String getRelativeSpec(in nsIURI aURIToCompare); |
| 182 |
| 183 }; |
OLD | NEW |