@@ -78,17 +78,39 @@ func roundUp(w int) int {
78
78
// more spaces + a non empty string containing no space or commas).
79
79
// Doesn't capture the initial space.
80
80
//
81
- // \s* Match, but don't capture leading spaces
81
+ // \s* Match, but don't capture leading spaces.
82
82
// (?:,\s*)? Optionally match comma and trailing space,
83
83
// but don't capture comma.
84
84
// ([^,\s]\S*[^,\s]) Match something like "google.com/favicon.ico"
85
- // but not ",google.com/favicon.ico,"
85
+ // but not ",google.com/favicon.ico,".
86
86
// \s* Match, but don't capture spaces.
87
- // ([\d]+.?[\d]*[w|x])? e.g. "5w" or "5x" or "10.2x"
87
+ // ( Match the width or density descriptor...
88
+ // [1-9]\d*[wx] which is a non-zero integer followed by a w
89
+ // or an x ...
90
+ // | or ...
91
+ // [1-9]\d*\.\d+x a decimal with its whole-number part greater
92
+ // than zero and followed by an x ...
93
+ // | or ...
94
+ // 0.\d*[1-9]\d*x a decimal with its fractional part greater
95
+ // than zero and followed by an x ...
96
+ // )? and make it optional.
88
97
// \s* Match, but don't capture space
89
98
// (?:(,)\s*)? Optionally match comma and trailing space,
90
99
// capturing comma.
91
- var imageCandidateRE = regexp .MustCompile (`\s*(?:,\s*)?([^,\s]\S*[^,\s])\s*([\d]+.?[\d]*[w|x])?\s*(?:(,)\s*)?` )
100
+ var imageCandidateRE = regexp .MustCompile (
101
+ `\s*` +
102
+ `(?:,\s*)?` +
103
+ `([^,\s]\S*[^,\s])` +
104
+ `\s*` +
105
+ `(` +
106
+ `[1-9]\d*[wx]` +
107
+ `|` +
108
+ `[1-9]\d*\.\d+x` +
109
+ `|` +
110
+ `0.\d*[1-9]\d*` +
111
+ `)?` +
112
+ `\s*` +
113
+ `(?:(,)\s*)?` )
92
114
93
115
// ParseSrcset parses the given srcset attribute value of its
94
116
// image candidates (as defined by
0 commit comments