@@ -6,56 +6,56 @@ import { describe, it, expect } from 'vitest';
6
6
import { serializeNodeWithId , _isBlockedElement } from '../src/snapshot' ;
7
7
import snapshot from '../src/snapshot' ;
8
8
import { serializedNodeWithId , elementNode } from '../src/types' ;
9
- import { Mirror , absoluteToStylesheet } from '../src/utils' ;
9
+ import { Mirror , absolutifyURLs } from '../src/utils' ;
10
10
11
11
describe ( 'absolute url to stylesheet' , ( ) => {
12
12
const href = 'http://localhost/css/style.css' ;
13
13
14
14
it ( 'can handle relative path' , ( ) => {
15
- expect ( absoluteToStylesheet ( 'url(a.jpg)' , href ) ) . toEqual (
15
+ expect ( absolutifyURLs ( 'url(a.jpg)' , href ) ) . toEqual (
16
16
`url(http://localhost/css/a.jpg)` ,
17
17
) ;
18
18
} ) ;
19
19
20
20
it ( 'can handle same level path' , ( ) => {
21
- expect ( absoluteToStylesheet ( 'url("./a.jpg")' , href ) ) . toEqual (
21
+ expect ( absolutifyURLs ( 'url("./a.jpg")' , href ) ) . toEqual (
22
22
`url("http://localhost/css/a.jpg")` ,
23
23
) ;
24
24
} ) ;
25
25
26
26
it ( 'can handle parent level path' , ( ) => {
27
- expect ( absoluteToStylesheet ( 'url("../a.jpg")' , href ) ) . toEqual (
27
+ expect ( absolutifyURLs ( 'url("../a.jpg")' , href ) ) . toEqual (
28
28
`url("http://localhost/a.jpg")` ,
29
29
) ;
30
30
} ) ;
31
31
32
32
it ( 'can handle absolute path' , ( ) => {
33
- expect ( absoluteToStylesheet ( 'url("/a.jpg")' , href ) ) . toEqual (
33
+ expect ( absolutifyURLs ( 'url("/a.jpg")' , href ) ) . toEqual (
34
34
`url("http://localhost/a.jpg")` ,
35
35
) ;
36
36
} ) ;
37
37
38
38
it ( 'can handle external path' , ( ) => {
39
- expect ( absoluteToStylesheet ( 'url("http://localhost/a.jpg")' , href ) ) . toEqual (
39
+ expect ( absolutifyURLs ( 'url("http://localhost/a.jpg")' , href ) ) . toEqual (
40
40
`url("http://localhost/a.jpg")` ,
41
41
) ;
42
42
} ) ;
43
43
44
44
it ( 'can handle single quote path' , ( ) => {
45
- expect ( absoluteToStylesheet ( `url('./a.jpg')` , href ) ) . toEqual (
45
+ expect ( absolutifyURLs ( `url('./a.jpg')` , href ) ) . toEqual (
46
46
`url('http://localhost/css/a.jpg')` ,
47
47
) ;
48
48
} ) ;
49
49
50
50
it ( 'can handle no quote path' , ( ) => {
51
- expect ( absoluteToStylesheet ( 'url(./a.jpg)' , href ) ) . toEqual (
51
+ expect ( absolutifyURLs ( 'url(./a.jpg)' , href ) ) . toEqual (
52
52
`url(http://localhost/css/a.jpg)` ,
53
53
) ;
54
54
} ) ;
55
55
56
56
it ( 'can handle multiple no quote paths' , ( ) => {
57
57
expect (
58
- absoluteToStylesheet (
58
+ absolutifyURLs (
59
59
'background-image: url(images/b.jpg);background: #aabbcc url(images/a.jpg) 50% 50% repeat;' ,
60
60
href ,
61
61
) ,
@@ -66,11 +66,11 @@ describe('absolute url to stylesheet', () => {
66
66
} ) ;
67
67
68
68
it ( 'can handle data url image' , ( ) => {
69
+ expect ( absolutifyURLs ( 'url(data:image/gif;base64,ABC)' , href ) ) . toEqual (
70
+ 'url(data:image/gif;base64,ABC)' ,
71
+ ) ;
69
72
expect (
70
- absoluteToStylesheet ( 'url(data:image/gif;base64,ABC)' , href ) ,
71
- ) . toEqual ( 'url(data:image/gif;base64,ABC)' ) ;
72
- expect (
73
- absoluteToStylesheet (
73
+ absolutifyURLs (
74
74
'url(data:application/font-woff;base64,d09GMgABAAAAAAm)' ,
75
75
href ,
76
76
) ,
@@ -79,23 +79,23 @@ describe('absolute url to stylesheet', () => {
79
79
80
80
it ( 'preserves quotes around inline svgs with spaces' , ( ) => {
81
81
expect (
82
- absoluteToStylesheet (
82
+ absolutifyURLs (
83
83
"url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='%2328a745' d='M3'/%3E%3C/svg%3E\")" ,
84
84
href ,
85
85
) ,
86
86
) . toEqual (
87
87
"url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='%2328a745' d='M3'/%3E%3C/svg%3E\")" ,
88
88
) ;
89
89
expect (
90
- absoluteToStylesheet (
90
+ absolutifyURLs (
91
91
'url(\'data:image/svg+xml;utf8,<svg width="28" height="32" viewBox="0 0 28 32" xmlns="http://www.w3.org/2000/svg"><path d="M27 14C28" fill="white"/></svg>\')' ,
92
92
href ,
93
93
) ,
94
94
) . toEqual (
95
95
'url(\'data:image/svg+xml;utf8,<svg width="28" height="32" viewBox="0 0 28 32" xmlns="http://www.w3.org/2000/svg"><path d="M27 14C28" fill="white"/></svg>\')' ,
96
96
) ;
97
97
expect (
98
- absoluteToStylesheet (
98
+ absolutifyURLs (
99
99
'url("data:image/svg+xml;utf8,<svg width="28" height="32" viewBox="0 0 28 32" xmlns="http://www.w3.org/2000/svg"><path d="M27 14C28" fill="white"/></svg>")' ,
100
100
href ,
101
101
) ,
@@ -104,7 +104,7 @@ describe('absolute url to stylesheet', () => {
104
104
) ;
105
105
} ) ;
106
106
it ( 'can handle empty path' , ( ) => {
107
- expect ( absoluteToStylesheet ( `url('')` , href ) ) . toEqual ( `url('')` ) ;
107
+ expect ( absolutifyURLs ( `url('')` , href ) ) . toEqual ( `url('')` ) ;
108
108
} ) ;
109
109
} ) ;
110
110
0 commit comments