我可以在 URL 中使用 at 符号 (@) 吗? [英] Can I use an at symbol (@) inside URLs?

查看:36
本文介绍了我可以在 URL 中使用 at 符号 (@) 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为用户的一部分使用 @ 符号是否安全?例如,一个可能的 URL 是 http://example.com/@dave.

Is it safe to use an @ symbol as part of a user? For example, a possible URL would be http://example.com/@dave.

这个想法是,现在用户通常被称为@user",那么为什么不将用户页面设为@username"呢?

The idea is that, nowadays, users are commonly called "@user", so why not make the user page "@username"?

推荐答案

百分比编码……

如果您percent,您可以在 HTTP URI 路径中使用 @ 字符- 编码%40.

许多浏览器仍将其显示为 @,但例如当您将 URI 复制并粘贴到文本文档中时,它将是 %40.

Many browsers would display it still as @, but e.g. when you copy-and-paste the URI into a text document, it will be %40.

您可以直接在 HTTP URI 路径中使用 @ 代替百分比编码.

Instead of percent-encoding it, you may use @ directly in the HTTP URI path.

查看 URI 的路径的语法.除了各种不相关的子句,路径可能由 segmentsegment-nzsegment-nz-nc 集合中的字符组成.segmentsegment-nzpchar 集合中的字符组成,定义为:

See the syntax for the path of an URI. Various unrelated clauses aside, the path may consist of characters in the segment, segment-nz, or segment-nz-nc set. segment and segment-nz consist of characters from the pchar set, which is defined as:

pchar = unreserved / pct-encoded / sub-delims / ":" / "@"

如您所见,@ 已明确列出.

As you can see, the @ is listed explicitly.

segment-nz-nc 集还明确列出了 @ 字符:

The segment-nz-nc set also lists the @ character explicitly:

segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )

所以,像这样的 HTTP URI 是完全有效的:

So, a HTTP URI like this is totally valid:

http://example.com/@dave

示例

这是一个维基百科页面示例:

Example

Here is an example Wikipedia page:

  • 链接
  • 复制粘贴:http://en.wikipedia.org/wiki/%22@%22_%28album%29

如您所见,"() 字符是百分比编码的,但 @code> 和 _ 直接使用.

As you can see, the ", (, and ) characters are percent-encoded, but the @ and the _ is used directly.

这篇关于我可以在 URL 中使用 at 符号 (@) 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆