Skip to content

Commit

Permalink
Update regex for recognizing x vs w descriptor in srcset
Browse files Browse the repository at this point in the history
Co-Authored-By: cathyxz <cathyxz@gmail.com>
  • Loading branch information
jridgewell and cathyxz authored Feb 27, 2019
1 parent 9495506 commit 7918faa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion builtins/amp-img.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class AmpImg extends BaseElement {
// Sizes is useless without the srcset attribute or if the srcset
// attribute uses the x descriptor.
const srcset = this.element.getAttribute('srcset');
if (!srcset || RegExp('[0-9]+x,.*|[0-9]+x$').test(srcset)) {
if (!srcset || /[0-9]+x(?:,|$)/.test(srcset)) {
return;
}

Expand Down

0 comments on commit 7918faa

Please sign in to comment.