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

新字节

我有一个 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>

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

班努瓦·布兰雄

OpenSearch的规范定义的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。
您必须使用绝对 URL,例如http://example.com/search?q={searchTerms}.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章