/gecko_sdk/idl/nsIURL.idl
IDL | 179 lines | 15 code | 17 blank | 147 comment | 0 complexity | 287d614d982720335dd8f6f5353cbc11 MD5 | raw file
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://host/directory/fileBaseName.fileExtension?query 47 * http://host/directory/fileBaseName.fileExtension#ref 48 * http://host/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)] 60interface 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://host/foo/bar.html#baz" 69 * is "/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. If the URL denotes a path to a 105 * directory and not a file, e.g. http://host/foo/bar/, then the Directory 106 * attribute accesses the complete /foo/bar/ portion, and the FileName is 107 * the empty string. If the trailing slash is omitted, then the Directory 108 * is /foo/ and the file is bar (i.e. this is a syntactic, not a semantic 109 * breakdown of the Path). And hence don't rely on this for something to 110 * be a definitely be a file. But you can get just the leading directory 111 * portion for sure. 112 * 113 * Some characters may be escaped. 114 */ 115 attribute AUTF8String directory; 116 117 /** 118 * Returns the file name portion of a URL. If the URL denotes a path to a 119 * directory and not a file, e.g. http://host/foo/bar/, then the Directory 120 * attribute accesses the complete /foo/bar/ portion, and the FileName is 121 * the empty string. Note that this is purely based on searching for the 122 * last trailing slash. And hence don't rely on this to be a definite file. 123 * 124 * Some characters may be escaped. 125 */ 126 attribute AUTF8String fileName; 127 128 129 /************************************************************************* 130 * The URL filename is broken down even further: 131 */ 132 133 /** 134 * Returns the file basename portion of a filename in a url. 135 * 136 * Some characters may be escaped. 137 */ 138 attribute AUTF8String fileBaseName; 139 140 /** 141 * Returns the file extension portion of a filename in a url. If a file 142 * extension does not exist, the empty string is returned. 143 * 144 * Some characters may be escaped. 145 */ 146 attribute AUTF8String fileExtension; 147 148 /** 149 * This method takes a uri and compares the two. The common uri portion 150 * is returned as a string. The minimum common uri portion is the 151 * protocol, and any of these if present: login, password, host and port 152 * If no commonality is found, "" is returned. If they are identical, the 153 * whole path with file/ref/etc. is returned. For file uris, it is 154 * expected that the common spec would be at least "file:///" since '/' is 155 * a shared common root. 156 * 157 * Examples: 158 * this.spec aURIToCompare.spec result 159 * 1) http://mozilla.org/ http://www.mozilla.org/ "" 160 * 2) http://foo.com/bar/ ftp://foo.com/bar/ "" 161 * 3) http://foo.com:8080/ http://foo.com/bar/ "" 162 * 4) ftp://user@foo.com/ ftp://user:pw@foo.com/ "" 163 * 5) ftp://foo.com/bar/ ftp://foo.com/bar ftp://foo.com/ 164 * 6) ftp://foo.com/bar/ ftp://foo.com/bar/b.html ftp://foo.com/bar/ 165 * 7) http://foo.com/a.htm#i http://foo.com/b.htm http://foo.com/ 166 * 8) ftp://foo.com/c.htm#i ftp://foo.com/c.htm ftp://foo.com/c.htm 167 * 9) file:///a/b/c.html file:///d/e/c.html file:/// 168 */ 169 AUTF8String getCommonBaseSpec(in nsIURI aURIToCompare); 170 171 /** 172 * This method takes a uri and returns a substring of this if it can be 173 * made relative to the uri passed in. If no commonality is found, the 174 * entire uri spec is returned. If they are identical, "" is returned. 175 * Filename, query, etc are always returned except when uris are identical. 176 */ 177 AUTF8String getRelativeSpec(in nsIURI aURIToCompare); 178 179};