1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/base/public/nsIURL.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,135 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsIURI.idl" 1.10 + 1.11 +/** 1.12 + * The nsIURL interface provides convenience methods that further 1.13 + * break down the path portion of nsIURI: 1.14 + * 1.15 + * http://host/directory/fileBaseName.fileExtension?query 1.16 + * http://host/directory/fileBaseName.fileExtension#ref 1.17 + * \ \ / 1.18 + * \ ----------------------- 1.19 + * \ | / 1.20 + * \ fileName / 1.21 + * ---------------------------- 1.22 + * | 1.23 + * filePath 1.24 + */ 1.25 +[scriptable, uuid(1419aa16-f134-4154-9886-00c7c5147a13)] 1.26 +interface nsIURL : nsIURI 1.27 +{ 1.28 + /************************************************************************* 1.29 + * The URL path is broken down into the following principal components: 1.30 + */ 1.31 + 1.32 + /** 1.33 + * Returns a path including the directory and file portions of a 1.34 + * URL. For example, the filePath of "http://host/foo/bar.html#baz" 1.35 + * is "/foo/bar.html". 1.36 + * 1.37 + * Some characters may be escaped. 1.38 + */ 1.39 + attribute AUTF8String filePath; 1.40 + 1.41 + /** 1.42 + * Returns the query portion (the part after the "?") of the URL. 1.43 + * If there isn't one, an empty string is returned. 1.44 + * 1.45 + * Some characters may be escaped. 1.46 + */ 1.47 + attribute AUTF8String query; 1.48 + 1.49 + 1.50 + /************************************************************************* 1.51 + * The URL filepath is broken down into the following sub-components: 1.52 + */ 1.53 + 1.54 + /** 1.55 + * Returns the directory portion of a URL. If the URL denotes a path to a 1.56 + * directory and not a file, e.g. http://host/foo/bar/, then the Directory 1.57 + * attribute accesses the complete /foo/bar/ portion, and the FileName is 1.58 + * the empty string. If the trailing slash is omitted, then the Directory 1.59 + * is /foo/ and the file is bar (i.e. this is a syntactic, not a semantic 1.60 + * breakdown of the Path). And hence don't rely on this for something to 1.61 + * be a definitely be a file. But you can get just the leading directory 1.62 + * portion for sure. 1.63 + * 1.64 + * Some characters may be escaped. 1.65 + */ 1.66 + attribute AUTF8String directory; 1.67 + 1.68 + /** 1.69 + * Returns the file name portion of a URL. If the URL denotes a path to a 1.70 + * directory and not a file, e.g. http://host/foo/bar/, then the Directory 1.71 + * attribute accesses the complete /foo/bar/ portion, and the FileName is 1.72 + * the empty string. Note that this is purely based on searching for the 1.73 + * last trailing slash. And hence don't rely on this to be a definite file. 1.74 + * 1.75 + * Some characters may be escaped. 1.76 + */ 1.77 + attribute AUTF8String fileName; 1.78 + 1.79 + 1.80 + /************************************************************************* 1.81 + * The URL filename is broken down even further: 1.82 + */ 1.83 + 1.84 + /** 1.85 + * Returns the file basename portion of a filename in a url. 1.86 + * 1.87 + * Some characters may be escaped. 1.88 + */ 1.89 + attribute AUTF8String fileBaseName; 1.90 + 1.91 + /** 1.92 + * Returns the file extension portion of a filename in a url. If a file 1.93 + * extension does not exist, the empty string is returned. 1.94 + * 1.95 + * Some characters may be escaped. 1.96 + */ 1.97 + attribute AUTF8String fileExtension; 1.98 + 1.99 + /** 1.100 + * This method takes a uri and compares the two. The common uri portion 1.101 + * is returned as a string. The minimum common uri portion is the 1.102 + * protocol, and any of these if present: login, password, host and port 1.103 + * If no commonality is found, "" is returned. If they are identical, the 1.104 + * whole path with file/ref/etc. is returned. For file uris, it is 1.105 + * expected that the common spec would be at least "file:///" since '/' is 1.106 + * a shared common root. 1.107 + * 1.108 + * Examples: 1.109 + * this.spec aURIToCompare.spec result 1.110 + * 1) http://mozilla.org/ http://www.mozilla.org/ "" 1.111 + * 2) http://foo.com/bar/ ftp://foo.com/bar/ "" 1.112 + * 3) http://foo.com:8080/ http://foo.com/bar/ "" 1.113 + * 4) ftp://user@foo.com/ ftp://user:pw@foo.com/ "" 1.114 + * 5) ftp://foo.com/bar/ ftp://foo.com/bar ftp://foo.com/ 1.115 + * 6) ftp://foo.com/bar/ ftp://foo.com/bar/b.html ftp://foo.com/bar/ 1.116 + * 7) http://foo.com/a.htm#i http://foo.com/b.htm http://foo.com/ 1.117 + * 8) ftp://foo.com/c.htm#i ftp://foo.com/c.htm ftp://foo.com/c.htm 1.118 + * 9) file:///a/b/c.html file:///d/e/c.html file:/// 1.119 + */ 1.120 + AUTF8String getCommonBaseSpec(in nsIURI aURIToCompare); 1.121 + 1.122 + /** 1.123 + * This method tries to create a string which specifies the location of the 1.124 + * argument relative to |this|. If the argument and |this| are equal, the 1.125 + * method returns "". If any of the URIs' scheme, host, userpass, or port 1.126 + * don't match, the method returns the full spec of the argument. 1.127 + * 1.128 + * Examples: 1.129 + * this.spec aURIToCompare.spec result 1.130 + * 1) http://mozilla.org/ http://www.mozilla.org/ http://www.mozilla.org/ 1.131 + * 2) http://mozilla.org/ http://www.mozilla.org http://www.mozilla.org/ 1.132 + * 3) http://foo.com/bar/ http://foo.com:80/bar/ "" 1.133 + * 4) http://foo.com/ http://foo.com/a.htm#b a.html#b 1.134 + * 5) http://foo.com/a/b/ http://foo.com/c ../../c 1.135 + */ 1.136 + AUTF8String getRelativeSpec(in nsIURI aURIToCompare); 1.137 + 1.138 +};