WebManifest.json中的范围,start_url和ID是否可以使用相对路径?

发布于 2025-02-13 04:22:23 字数 347 浏览 0 评论 0原文

假设我们有一个可以通过不同环境获得的Web应用程序:

nightly.my-app.com
test.my-app.com
my-app.com

使用WebManifest.json我们要标识应用程序的每个版本,但是我们不想为每个构建创建另一个WebManifest。因此,我们使用了这些值:

"scope": "./",
"start_url": "./",
"id": "./",

我的问题是:

这些值有效吗?浏览器/设备会自动解决应用程序的实际URL的所有值吗?

Let's say we have a web application which is available through different environments:

nightly.my-app.com
test.my-app.com
my-app.com

Using webmanifest.json we want to identify each version of our app, but we don't want to create a different webmanifest for each build. So we used these values:

"scope": "./",
"start_url": "./",
"id": "./",

My questions are:

Are these values valid? Will the browser/ device automatically resolve all values to the actual URL of the app?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼趣 2025-02-20 04:22:23

当您定义范围时,所有路径都将与之相关。

参考 devrapterer.mozilla.org

范围成员是一个字符串,可定义此Web应用程序上下文的导航范围。它限制了在应用清单时可以查看哪些网页。如果用户在范围外导航,它将恢复为浏览器选项卡或窗口内的普通网页。

它还说:

如果范围是相对URL,则基本URL将是清单的URL。

所以不用担心。这是合法的,可以正常工作。

When you define scope all the paths will be relative to that.

referring to developer.mozilla.org:

The scope member is a string that defines the navigation scope of this web application's application context. It restricts what web pages can be viewed while the manifest is applied. If the user navigates outside the scope, it reverts to a normal web page inside a browser tab or window.

It also says:

If the scope is a relative URL, the base URL will be the URL of the manifest.

So don't worry. this is legit and will work fine.

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