Skip to main content

function-url-scheme-allowed-list

指定允许的 URL 方案列表。

¥Specify a list of allowed URL schemes.

a { background-image: url('http://www.example.com/file.jpg'); }
/** ↑

* This URL scheme */

网址方案 由字母数字、+-. 字符组成。它可以出现在 URL 的开头,后跟 :

¥A URL scheme consists of alphanumeric, +, -, and . characters. It can appear at the start of a URL and is followed by :.

该规则忽略了:

¥This rule ignores:

  • 没有现有 URL 方案的 URL 参数

    ¥URL arguments without an existing URL scheme

  • 带有变量或变量插值的 URL 参数($sass@less--custom-property#{$var}@{var}$(var)

    ¥URL arguments with variables or variable interpolation ($sass, @less, --custom-property, #{$var}, @{var}, $(var))

message 次要选项 可以接受该规则的参数。

¥The message secondary option can accept the arguments of this rule.

选项

¥Options

array|string|regex["array", "of", /schemes/, "/regex/"]|"scheme"|"/regex/"|/regex/

鉴于:

¥Given:

["data", "/^http/"]

以下模式被视为问题:

¥The following patterns are considered problems:

a { background-image: url('file://file.jpg'); }

以下模式不被视为问题:

¥The following patterns are not considered problems:

a { background-image: url('example.com/file.jpg'); }
a { background-image: url('/example.com/file.jpg'); }
a { background-image: url('//example.com/file.jpg'); }
a { background-image: url('./path/to/file.jpg'); }
a { background-image: url('http://www.example.com/file.jpg'); }
a { background-image: url('https://www.example.com/file.jpg'); }
a { background-image: url('HTTPS://www.example.com/file.jpg'); }
a { background-image: url('data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs='); }