-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rum-recorder: import rrweb-snapshot code (#700)
* rum-recorder: import rrweb-snapshot code This commit removes the dependency on rrweb-snapshot and instead adds the code directly, changing the imports accordingly. * licenses: update 3p following embedding of rrweb-snapshot * rum-recorder: remove unused code in rrweb-snapshot * rum-recorder: address eslint issues * rum-recorder: capitalize first letter of types * rum-recorder: replace string.match() by RegExp.test() * rum-recorder: add rrweb-snapshot unit tests * rum-recorder: remove unused types
- Loading branch information
Showing
13 changed files
with
770 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { serializeNodeWithId, transformAttribute, IGNORED_NODE, snapshot } from './snapshot' | ||
export * from './types' | ||
|
||
export { snapshot, serializeNodeWithId, transformAttribute, IGNORED_NODE } |
75 changes: 75 additions & 0 deletions
75
packages/rum-recorder/src/domain/rrweb-snapshot/snapshot.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* eslint-disable max-len */ | ||
import { absoluteToStylesheet } from './snapshot' | ||
|
||
describe('absolute url to stylesheet', () => { | ||
const href = 'http://localhost/css/style.css' | ||
|
||
it('can handle relative path', () => { | ||
expect(absoluteToStylesheet('url(a.jpg)', href)).toEqual(`url(http://localhost/css/a.jpg)`) | ||
}) | ||
|
||
it('can handle same level path', () => { | ||
expect(absoluteToStylesheet('url("./a.jpg")', href)).toEqual(`url("http://localhost/css/a.jpg")`) | ||
}) | ||
|
||
it('can handle parent level path', () => { | ||
expect(absoluteToStylesheet('url("../a.jpg")', href)).toEqual(`url("http://localhost/a.jpg")`) | ||
}) | ||
|
||
it('can handle absolute path', () => { | ||
expect(absoluteToStylesheet('url("/a.jpg")', href)).toEqual(`url("http://localhost/a.jpg")`) | ||
}) | ||
|
||
it('can handle external path', () => { | ||
expect(absoluteToStylesheet('url("http://localhost/a.jpg")', href)).toEqual(`url("http://localhost/a.jpg")`) | ||
}) | ||
|
||
it('can handle single quote path', () => { | ||
expect(absoluteToStylesheet(`url('./a.jpg')`, href)).toEqual(`url('http://localhost/css/a.jpg')`) | ||
}) | ||
|
||
it('can handle no quote path', () => { | ||
expect(absoluteToStylesheet('url(./a.jpg)', href)).toEqual(`url(http://localhost/css/a.jpg)`) | ||
}) | ||
|
||
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 | ||
) | ||
).toEqual( | ||
`background-image: url(http://localhost/css/images/b.jpg);` + | ||
`background: #aabbcc url(http://localhost/css/images/a.jpg) 50% 50% repeat;` | ||
) | ||
}) | ||
|
||
it('can handle data url image', () => { | ||
expect(absoluteToStylesheet('url(data:image/gif;base64,ABC)', href)).toEqual('url(data:image/gif;base64,ABC)') | ||
expect(absoluteToStylesheet('url(data:application/font-woff;base64,d09GMgABAAAAAAm)', href)).toEqual( | ||
'url(data:application/font-woff;base64,d09GMgABAAAAAAm)' | ||
) | ||
}) | ||
|
||
it('preserves quotes around inline svgs with spaces', () => { | ||
expect( | ||
absoluteToStylesheet( | ||
"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\")", | ||
href | ||
) | ||
).toEqual( | ||
"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\")" | ||
) | ||
expect( | ||
absoluteToStylesheet( | ||
'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>\')', | ||
href | ||
) | ||
).toEqual( | ||
'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>\')' | ||
) | ||
}) | ||
it('can handle empty path', () => { | ||
expect(absoluteToStylesheet(`url('')`, href)).toEqual(`url('')`) | ||
}) | ||
}) |
Oops, something went wrong.