tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsIURL.idl (5652B)


      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/. */
      5 
      6 #include "nsIURI.idl"
      7 interface nsIURIMutator;
      8 
      9 /**
     10 * The nsIURL interface provides convenience methods that further
     11 * break down the path portion of nsIURI:
     12 *
     13 * http://host/directory/fileBaseName.fileExtension?query
     14 * http://host/directory/fileBaseName.fileExtension#ref
     15 *            \          \                       /
     16 *             \          -----------------------
     17 *              \                   |          /
     18 *               \               fileName     /
     19 *                ----------------------------
     20 *                            |
     21 *                        filePath
     22 */
     23 [scriptable, builtinclass, uuid(86adcd89-0b70-47a2-b0fe-5bb2c5f37e31)]
     24 interface nsIURL : nsIURI
     25 {
     26    /*************************************************************************
     27     * The URL path is broken down into the following principal components:
     28     *
     29     * attribute AUTF8String filePath;
     30     * attribute AUTF8String query;
     31     *
     32     * These are inherited from nsIURI.
     33     */
     34 
     35    /*************************************************************************
     36     * The URL filepath is broken down into the following sub-components:
     37     */
     38 
     39    /**
     40     * Returns the directory portion of a URL.  If the URL denotes a path to a
     41     * directory and not a file, e.g. http://host/foo/bar/, then the Directory
     42     * attribute accesses the complete /foo/bar/ portion, and the FileName is
     43     * the empty string. If the trailing slash is omitted, then the Directory
     44     * is /foo/ and the file is bar (i.e. this is a syntactic, not a semantic
     45     * breakdown of the Path).  And hence don't rely on this for something to
     46     * be a definitely be a file. But you can get just the leading directory
     47     * portion for sure.
     48     *
     49     * Some characters may be escaped.
     50     */
     51    readonly attribute AUTF8String directory;
     52 
     53    /**
     54     * Returns the file name portion of a URL.  If the URL denotes a path to a
     55     * directory and not a file, e.g. http://host/foo/bar/, then the Directory
     56     * attribute accesses the complete /foo/bar/ portion, and the FileName is
     57     * the empty string. Note that this is purely based on searching for the
     58     * last trailing slash. And hence don't rely on this to be a definite file.
     59     *
     60     * Some characters may be escaped.
     61     */
     62    readonly attribute AUTF8String fileName;
     63 
     64    /*************************************************************************
     65     * The URL filename is broken down even further:
     66     */
     67 
     68    /**
     69     * Returns the file basename portion of a filename in a url.
     70     *
     71     * Some characters may be escaped.
     72     */
     73    readonly attribute AUTF8String fileBaseName;
     74 
     75    /**
     76     * Returns the file extension portion of a filename in a url.  If a file
     77     * extension does not exist, the empty string is returned.
     78     *
     79     * Some characters may be escaped.
     80     */
     81    readonly attribute AUTF8String fileExtension;
     82 
     83    /**
     84     * This method takes a uri and compares the two.  The common uri portion
     85     * is returned as a string.  The minimum common uri portion is the
     86     * protocol, and any of these if present:  login, password, host and port
     87     * If no commonality is found, "" is returned.  If they are identical, the
     88     * whole path with file/ref/etc. is returned.  For file uris, it is
     89     * expected that the common spec would be at least "file:///" since '/' is
     90     * a shared common root.
     91     *
     92     * Examples:
     93     *    this.spec               aURIToCompare.spec        result
     94     * 1) http://mozilla.org/     http://www.mozilla.org/   ""
     95     * 2) http://foo.com/bar/     ftp://foo.com/bar/        ""
     96     * 3) http://foo.com:8080/    http://foo.com/bar/       ""
     97     * 4) ftp://user@foo.com/     ftp://user:pw@foo.com/    ""
     98     * 5) ftp://foo.com/bar/      ftp://foo.com/bar         ftp://foo.com/
     99     * 6) ftp://foo.com/bar/      ftp://foo.com/bar/b.html  ftp://foo.com/bar/
    100     * 7) http://foo.com/a.htm#i  http://foo.com/b.htm      http://foo.com/
    101     * 8) ftp://foo.com/c.htm#i   ftp://foo.com/c.htm       ftp://foo.com/c.htm
    102     * 9) file:///a/b/c.html      file:///d/e/c.html        file:///
    103     */
    104    AUTF8String getCommonBaseSpec(in nsIURI aURIToCompare);
    105 
    106    /**
    107     * This method tries to create a string which specifies the location of the
    108     * argument relative to |this|.  If the argument and |this| are equal, the
    109     * method returns "".  If any of the URIs' scheme, host, userpass, or port
    110     * don't match, the method returns the full spec of the argument.
    111     *
    112     * Examples:
    113     *    this.spec               aURIToCompare.spec        result
    114     * 1) http://mozilla.org/     http://www.mozilla.org/   http://www.mozilla.org/
    115     * 2) http://mozilla.org/     http://www.mozilla.org    http://www.mozilla.org/
    116     * 3) http://foo.com/bar/     http://foo.com:80/bar/    ""
    117     * 4) http://foo.com/         http://foo.com/a.htm#b    a.html#b
    118     * 5) http://foo.com/a/b/     http://foo.com/c          ../../c
    119     */
    120    AUTF8String getRelativeSpec(in nsIURI aURIToCompare);
    121 
    122 };
    123 
    124 [scriptable, builtinclass, uuid(25072eb8-f1e6-482f-9ca9-eddd3d65169a)]
    125 interface nsIURLMutator : nsISupports
    126 {
    127    [must_use] nsIURIMutator setFileName(in AUTF8String aFileName);
    128    [must_use] nsIURIMutator setFileBaseName(in AUTF8String aFileBaseName);
    129    [must_use] nsIURIMutator setFileExtension(in AUTF8String aFileExtension);
    130 };