Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var WHITESPACE_REGEX = /^\s*/;
// declaration
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
var COLON_REGEX = /^:\s*/;
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|[^};])+)/;
var SEMICOLON_REGEX = /^[;\s]*/;

// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
Expand Down
42 changes: 42 additions & 0 deletions test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,48 @@ exports[`inline-style-parser parses multiple declarations 1`] = `
]
`;

exports[`inline-style-parser parses semicolon and parenthesis inside double quoted url 1`] = `
[
{
"position": Position {
"end": {
"column": 35,
"line": 1,
},
"source": undefined,
"start": {
"column": 1,
"line": 1,
},
},
"property": "background",
"type": "declaration",
"value": "url("a)b;c") no-repeat",
},
]
`;

exports[`inline-style-parser parses semicolon and parenthesis inside single quoted url 1`] = `
[
{
"position": Position {
"end": {
"column": 35,
"line": 1,
},
"source": undefined,
"start": {
"column": 1,
"line": 1,
},
},
"property": "background",
"type": "declaration",
"value": "url('a)b;c') no-repeat",
},
]
`;

exports[`inline-style-parser parses single declaration 1`] = `
[
{
Expand Down
16 changes: 15 additions & 1 deletion test/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ const cases = [
'content: "Lorem ipsum";',
'content: "foo: bar;";',
'background-image: url(http://example.com/img.png)',
'background: #123456 url("https://foo.bar/image.png?v=2")',
'background: #123456 url("https://example.com/img.png?v=2&a=b")',
'background-image: url("http://example.com/img.png")',
"background-image: url('http://example.com/img.png')",
'background: url(http://example.com/img.png) no-repeat',
'background: url("data:image/svg+xml,<svg/>")',

// vendor prefixes
'background: -webkit-linear-gradient(90deg, black, #111)',
Expand Down Expand Up @@ -60,6 +64,16 @@ const snapshots = [

['parses single declaration', 'background-color: #C0FFEE;'],

// https://github.com/remarkablemark/inline-style-parser/issues/550
[
'parses semicolon and parenthesis inside double quoted url',
'background: url("a)b;c") no-repeat;'
],
[
'parses semicolon and parenthesis inside single quoted url',
"background: url('a)b;c') no-repeat;"
],

[
'parses multiple declarations',
`
Expand Down