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.

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

mercurial