nsIStandardURL 编辑

netwerk/base/public/nsIStandardURL.idlScriptable This interface defines the interface to an URL with the standard file path format common to protocols like http, ftp, and file. It supports initialization from a relative path and provides some customization on how URLs are normalized. Inherits from: nsIMutable Last changed in Gecko 1.9 (Firefox 3)

Implemented by: @mozilla.org/network/standard-url;1. To create an instance, use:

var standardURL = Components.classes["@mozilla.org/network/standard-url;1"]
                  .createInstance(Components.interfaces.nsIStandardURL);

Method overview

void init(in unsigned long aUrlType, in long aDefaultPort, in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI);

Attributes

AttributeTypeDescription
mutablebooleanControl whether or not this URL can be modified. Protocol handlers can set this flag before handing out an URL to ensure that it is not inadvertently modified. Obsolete since Gecko 1.9

Constants

These constants describe how to normalize an URL.

ConstantValueDescription
URLTYPE_STANDARD1
blah:foo/bar    => blah://foo/bar
blah:/foo/bar   => blah:///foo/bar
blah://foo/bar  => blah://foo/bar
blah:///foo/bar => blah:///foo/bar
URLTYPE_AUTHORITY2
blah:foo/bar    => blah://foo/bar
blah:/foo/bar   => blah://foo/bar
blah://foo/bar  => blah://foo/bar
blah:///foo/bar => blah://foo/bar
URLTYPE_NO_AUTHORITY3
blah:foo/bar    => blah:///foo/bar
blah:/foo/bar   => blah:///foo/bar
blah://foo/bar  => blah://foo/bar
blah:///foo/bar => blah:///foo/bar

Methods

init()

Normalizes a given URL to an Standard URL.

void init(
  in unsigned long aUrlType,
  in long aDefaultPort,
  in AUTF8String aSpec,
  in string aOriginCharset,
  in nsIURI aBaseURI
);
Parameters
aUrlType
One of the constants listed above.
aDefaultPort
If the port parsed from the URL string matches this port, then the port will be removed from the canonical form of the URL.
aSpec
URL string.
aOriginCharset
The charset from which this URI string originated. this corresponds to the charset that should be used when communicating this URI to an origin server, for example. if null, then provide aBaseURI implements this interface, the origin charset of aBaseURI will be assumed, otherwise defaulting to UTF-8 (that is, no charset transformation from aSpec).
aBaseURI
If null, aSpec must specify an absolute URI. Otherwise, aSpec will be resolved relative to aBaseURI.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:41 次

字数:4618

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文