UNPKG

1.87 kBMarkdownView Raw
1# function-url-scheme-whitelist
2
3**_Deprecated: Instead use the [`function-url-scheme-allowed-list`](../function-url-scheme-allowed-list/README.md) rule._**
4
5Specify a list of allowed URL schemes.
6
7<!-- prettier-ignore -->
8```css
9a { background-image: url('http://www.example.com/file.jpg'); }
10/** ↑
11 * This URL scheme */
12```
13
14A [URL scheme](https://url.spec.whatwg.org/#syntax-url-scheme) consists of alphanumeric, `+`, `-`, and `.` characters. It can appear at the start of a URL and is followed by `:`.
15
16This rule ignores:
17
18- URL arguments without an existing URL scheme
19- URL arguments with variables or variable interpolation (`$sass`, `@less`, `--custom-property`, `#{$var}`, `@{var}`, `$(var)`)
20
21## Options
22
23`array|string|regex`: `["array", "of", /schemes/ or "/regex/"]|"scheme"|/regex/`
24
25Given:
26
27```
28["data", "/^http/"]
29```
30
31The following patterns are considered violations:
32
33<!-- prettier-ignore -->
34```css
35a { background-image: url('file://file.jpg'); }
36```
37
38The following patterns are _not_ considered violations:
39
40<!-- prettier-ignore -->
41```css
42a { background-image: url('example.com/file.jpg'); }
43```
44
45<!-- prettier-ignore -->
46```css
47a { background-image: url('/example.com/file.jpg'); }
48```
49
50<!-- prettier-ignore -->
51```css
52a { background-image: url('//example.com/file.jpg'); }
53```
54
55<!-- prettier-ignore -->
56```css
57a { background-image: url('./path/to/file.jpg'); }
58```
59
60<!-- prettier-ignore -->
61```css
62a { background-image: url('http://www.example.com/file.jpg'); }
63```
64
65<!-- prettier-ignore -->
66```css
67a { background-image: url('https://www.example.com/file.jpg'); }
68```
69
70<!-- prettier-ignore -->
71```css
72a { background-image: url('HTTPS://www.example.com/file.jpg'); }
73```
74
75<!-- prettier-ignore -->
76```css
77a { background-image: url('data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs='); }
78```