fix the format and use window.location
This commit is contained in:
@@ -107,7 +107,7 @@ function serializeNode(n: Node, doc: Document): serializedNode | false {
|
||||
if (name === 'src' || name === 'href') {
|
||||
attributes[name] = absoluteToDoc(doc, value);
|
||||
} else if (name === 'style') {
|
||||
attributes[name] = absoluteToStylesheet(value, doc.location.href);
|
||||
attributes[name] = absoluteToStylesheet(value, location.href);
|
||||
} else {
|
||||
attributes[name] = value;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,14 @@ describe('absolute url to stylesheet', () => {
|
||||
});
|
||||
|
||||
it('can handle multiple no quote paths', () => {
|
||||
expect(absoluteToStylesheet('background-image: url(images/b.jpg); background: #aabbcc url(images/a.jpg) 50% 50% repeat;', href)).to.equal(
|
||||
`background-image: url('http://localhost/css/images/b.jpg'); background: #aabbcc url('http://localhost/css/images/a.jpg') 50% 50% repeat;`,
|
||||
expect(
|
||||
absoluteToStylesheet(
|
||||
'background-image: url(images/b.jpg); background: #aabbcc url(images/a.jpg) 50% 50% repeat;',
|
||||
href,
|
||||
),
|
||||
).to.equal(
|
||||
`background-image: url('http://localhost/css/images/b.jpg');` +
|
||||
`background: #aabbcc url('http://localhost/css/images/a.jpg') 50% 50% repeat;`,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user