在URI路径中放置句点是否是不良实践?

6 浏览
0 Comments

在URI路径中放置句点是否是不良实践?

我正在设计一个用于网络应用的REST API。我希望清晰地对API进行版本控制,以便将来可以更改接口而不影响现有服务。因此,在我的v1.0 API中,我希望明确将其标识为v1.0 API,这样我就可以自由地发布一个带有破坏性更改的v1.1版本。\n我的问题是,在URI的路径组件中使用句点是否是一种不良做法?\n例如,是否有任何好的理由不使用http://example.com/myapi/v1.0/services作为我的服务的URI?

0
0 Comments

在URI路径中放置句点是否是一个不好的做法?

有些人可能会认为在URI路径中放置句点是不好的做法,但实际上,根据规范,句点是一个合法的路径字符(valid path character)。在规范的第27页可以找到相关信息,可以点击这里查看完整规范。

因此,没有理由不使用句点作为URI路径的一部分。

解决方法:没有特定的问题需要解决,因为在URI路径中放置句点是合法的。如果你遇到了问题,需要检查其他方面的代码或配置。

0
0 Comments

在URI路径中使用句点是完全可以接受的。根据RFC 3986第2.3节,这也是有效的。

However, there are some cases where using a period in a URI path may cause problems. This is because some web servers and frameworks treat a period as a special character and may not handle it correctly. It can lead to issues such as 404 errors or incorrect routing.

然而,在某些情况下,在URI路径中使用句点可能会导致问题。这是因为一些Web服务器和框架将句点视为特殊字符,可能无法正确处理它。这可能导致404错误或错误的路由等问题。

To avoid these issues, it is recommended to use URL encoding when including a period in a URI path. URL encoding replaces special characters with percent-encoded representations. In the case of a period, it is replaced with "%2E". This ensures that the period is treated as a regular character and not as a special character.

为了避免这些问题,建议在URI路径中使用句点时使用URL编码。URL编码将特殊字符替换为百分号编码表示。对于句点,它将被替换为"%2E"。这确保句点被视为普通字符而不是特殊字符。

For example, if you want to include a file extension in the URI path, such as ".html", you can encode it as "%2Ehtml". This ensures that the web server or framework will correctly handle the period.

例如,如果您想在URI路径中包含文件扩展名,比如".html",您可以将其编码为"%2Ehtml"。这可以确保Web服务器或框架能够正确处理句点。

In summary, while it is generally acceptable to use a period in a URI path, it is important to be aware of the potential issues it may cause with certain web servers and frameworks. Using URL encoding can help avoid these problems and ensure that the period is treated as a regular character.

0
0 Comments

在URI中放置句点是完全可以接受的。在URI中放置版本号绝对不是最佳做法。为什么这样说呢?我在这里给出了一些理由,还有这里有一篇非常棒的文章,由比我聪明得多的某人撰写。

再次感谢Darren。通过你的链接,Shonzilla对这个问题的回答说服了我,版本控制可能不是一个好主意。然而,我关心的是,如果我使用这种方法来处理重大变更,非浏览器客户端(如使用我的服务的PHP网站)是否能够处理HTTP重定向?

0