nsIURIFixup 编辑

docshell/base/nsIURIFixup.idlScriptable Interface implemented by objects capable of fixing up strings into URIs. Inherits from: nsISupports Last changed in Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6)

Implemented by: @mozilla.org/docshell/urifixup;1 as a service:

var uriFixup = Components.classes["@mozilla.org/docshell/urifixup;1"]
               .createInstance(Components.interfaces.nsIURIFixup);

Method overview

nsIURI createExposableURI(in nsIURI aURI);
nsIURI createFixupURI(in AUTF8String aURIText, in unsigned long aFixupFlags);
nsIURI keywordToURI(in AUTF8String aKeyword);
nsIURIFixupInfo getFixupURIInfo(in AUTF8String aURIText, in unsigned long aFixupFlags);

Constants

ConstantValueDescription
FIXUP_FLAG_NONE0No fixup flags.
FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP1Allow the fixup to use a keyword lookup service to complete the URI. The fixup object implementer should honour this flag and only perform any lengthy keyword (or search) operation if it is set.
FIXUP_FLAGS_MAKE_ALTERNATE_URI2Tell the fixup to make an alternate URI from the input URI, for example to turn foo into www.foo.com.
FIXUP_FLAG_USE_UTF84Use UTF-8 to encode the URI instead of the platform character set.
FIXUP_FLAG_FIX_SCHEME_TYPOS8Fix common scheme typos.

Methods

createExposableURI()

Converts an internal URI (for example a WYSIWYG URI) into one which we can expose to the user, for example on the URL bar.

nsIURI createExposableURI(
  in nsIURI aURI
);
Parameters
aURI
The URI to be converted.
Return value

The converted, exposable URI, as an nsIURI.

Exceptions thrown
NS_ERROR_UNKNOWN_PROTOCOL
When we can not get a protocol handler service for the URI scheme.
NS_ERROR_MALFORMED_URI
When the exposable portion of aURI is malformed.

createFixupURI()

Converts the specified string into a URI, first attempting to correct any errors in the syntax or other vagaries. Returns a well formed URI or nsnull if it cannot.

nsIURI createFixupURI(
  in AUTF8String aURIText,
  in unsigned long aFixupFlags
);
Parameters
aURIText
Candidate URI.
aFixupFlags
Flags that govern ways the URI may be fixed up.
Return value

The converted URI.

keywordToURI()

Converts the specified keyword string into a URI. Note that it is the caller's responsibility to check whether keywords are enabled and whether aKeyword is a sensible keyword.

nsIURI keywordToURI(
  in AUTF8String aKeyword
);
Parameters
aKeyword
The keyword to convert into a URI.
Return value

The converted URI.

getFixupURIInfo()

Same as createFixupURI, but returns information about what it corrected (e.g. whether we could rescue the URI or "just" generated a keyword search URI instead).

nsIURI createFixupURI(
  in AUTF8String aURIText,
  in unsigned long aFixupFlags
);
Parameters
aURIText
Candidate URI.
aFixupFlags
Flags that govern ways the URI may be fixed up.
Return value

The information as an nsIURIFixupInfo

See also

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

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

发布评论

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

词条统计

浏览:70 次

字数:6245

最后编辑:7年前

编辑次数:0 次

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