UNPKG

1.75 kBMarkdownView Raw
1# function-url-scheme-allowed-list
2
3Specify a list of allowed URL schemes.
4
5<!-- prettier-ignore -->
6```css
7a { background-image: url('http://www.example.com/file.jpg'); }
8/** ↑
9 * This URL scheme */
10```
11
12A [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
14This 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
23Given:
24
25```
26["data", "/^http/"]
27```
28
29The following patterns are considered violations:
30
31<!-- prettier-ignore -->
32```css
33a { background-image: url('file://file.jpg'); }
34```
35
36The following patterns are _not_ considered violations:
37
38<!-- prettier-ignore -->
39```css
40a { background-image: url('example.com/file.jpg'); }
41```
42
43<!-- prettier-ignore -->
44```css
45a { background-image: url('/example.com/file.jpg'); }
46```
47
48<!-- prettier-ignore -->
49```css
50a { background-image: url('//example.com/file.jpg'); }
51```
52
53<!-- prettier-ignore -->
54```css
55a { background-image: url('./path/to/file.jpg'); }
56```
57
58<!-- prettier-ignore -->
59```css
60a { background-image: url('http://www.example.com/file.jpg'); }
61```
62
63<!-- prettier-ignore -->
64```css
65a { background-image: url('https://www.example.com/file.jpg'); }
66```
67
68<!-- prettier-ignore -->
69```css
70a { background-image: url('HTTPS://www.example.com/file.jpg'); }
71```
72
73<!-- prettier-ignore -->
74```css
75a { background-image: url('data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs='); }
76```