-
-
Notifications
You must be signed in to change notification settings - Fork 32
feat!: support parseable URL values #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,4 +28,31 @@ describe('word parsing', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(nodes).toMatchSnapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const urlFixtures = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { fixture: 'url(https://example.com/image.png)', label: 'unquoted absolute URL' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { fixture: "url('https://example.com/image.png')", label: 'single-quoted absolute URL' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { fixture: 'url("https://example.com/image.png")', label: 'double-quoted absolute URL' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { fixture: 'url(/images/image.png)', label: 'unquoted relative URL' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { fixture: "url('/images/image.png')", label: 'single-quoted relative URL' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { fixture: 'url("/images/image.png")', label: 'double-quoted relative URL' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { fixture: 'url(//cdn.example.com/image.png)', label: 'protocol-relative URL' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { fixture: 'url()', label: 'empty URL value' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+33
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are both mislabeled and incomplete. There are three types of meaningful URL—protocol-absolute, file-absolute, and file-relative—and valid inputs can include both query strings (e.g.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const { fixture, label } of urlFixtures) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it(`should expose URL metadata for: ${label}`, () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const root = parse(fixture); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const node = root.first as any; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input: fixture, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output: nodeToString(root), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: node.type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value: node.value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isUrl: node.isUrl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isParseableUrl: node.isParseableUrl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }).toMatchSnapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.