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