搜索插件XML中是否可以有相对路径? (OpenSearch)

我有一个适用于Web应用程序的Open Search XML,它看起来像这样:

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
    <ShortName>AppName</ShortName>
    <Description>Search App</Description>
    <InputEncoding>UTF-8</InputEncoding>
    <Image width="32" height="32" type="image/png">https://not.my.app.url/public/favicon.png</Image>
    <Url type="text/html" method="get" template="https://not.my.app.url/$/search?q={searchTerms}"/>
</OpenSearchDescription>

一个问题是,如果我想将应用程序托管在与https://not.my.app.url不同的URL上,则必须手动编辑清单以匹配新的主机名,或者使用某种预处理器将正确的名称那里的主机名。有什么办法可以代替我的相对路径吗?我只是尝试省略主机名和协议说明符,但随后Firefox拒绝将其安装为搜索提供程序(我未测试任何其他浏览器)。

iCMS 回答:搜索插件XML中是否可以有相对路径? (OpenSearch)

OpenSearch specification 将 URL 模板语法定义为:

ttemplate      = tscheme ":" thier-part [ "?" tquery ] [ "#" fragment ]
tscheme        = *( scheme / tparameter )
thier-part     = "//" tauthority ( tpath-abempty / tpath-absolute / tpath-rootless / path-empty )
tauthority     = [ tuserinfo "@" ] thost [ ":" tport ]
tuserinfo      = *( userinfo / tparameter )
thost          = *( host / tparameter )
tport          = *( port / tparameter )
tpath-abempty  = *( "/" tsegment )
tsegment       = *( segment / tparameter )
tpath-absolute = "/" [ tsegment-nz *( "/" tsegment ) ]
tsegment-nz    = *( segment-nz / tparameter )
tpath-rootless = tsegment-nz *( "/" tsegment )
tparameter     = "{" tqname [ tmodifier ] "}"
tqname         = [ tprefix ":" ] tlname
tprefix        = *pchar
tlname         = *pchar
tmodifier      = "?"
tquery         = *( query / tparameter )
tfragement     = *( fragement / tparameter )

如您所见,方案和主机是必需的。

换句话说,不允许使用相对 URL。
您必须使用绝对网址,例如 http://example.com/search?q={searchTerms}

本文链接:https://www.f2er.com/1785714.html

大家都在问