nsIURL.idl 5.1 KB

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