diff --git a/src/core/const.js b/src/core/const.js index fa2befa..37a9741 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -318,7 +318,7 @@ * @type {RegExp|string} * @example `` */ -export const SVG_SIZE = /]*(?:\s(width|height)="(\d*(?:\.\d+)?)(?:px)?")[^>]*(?:\s(width|height)="(\d*(?:\.\d+)?)(?:px)?")[^>]*>/i; // eslint-disable-line max-len +export const SVG_SIZE = /]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i; // eslint-disable-line max-len /** * Constants that identify shapes, mainly to prevent `instanceof` calls. diff --git a/src/core/const.js b/src/core/const.js index fa2befa..37a9741 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -318,7 +318,7 @@ * @type {RegExp|string} * @example `` */ -export const SVG_SIZE = /]*(?:\s(width|height)="(\d*(?:\.\d+)?)(?:px)?")[^>]*(?:\s(width|height)="(\d*(?:\.\d+)?)(?:px)?")[^>]*>/i; // eslint-disable-line max-len +export const SVG_SIZE = /]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i; // eslint-disable-line max-len /** * Constants that identify shapes, mainly to prevent `instanceof` calls. diff --git a/src/core/utils/index.js b/src/core/utils/index.js index 8ca64ce..20b559b 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -163,8 +163,8 @@ if (sizeMatch) { - size[sizeMatch[1]] = Math.round(parseFloat(sizeMatch[2])); - size[sizeMatch[3]] = Math.round(parseFloat(sizeMatch[4])); + size[sizeMatch[1]] = Math.round(parseFloat(sizeMatch[3])); + size[sizeMatch[5]] = Math.round(parseFloat(sizeMatch[7])); } return size; diff --git a/src/core/const.js b/src/core/const.js index fa2befa..37a9741 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -318,7 +318,7 @@ * @type {RegExp|string} * @example `` */ -export const SVG_SIZE = /]*(?:\s(width|height)="(\d*(?:\.\d+)?)(?:px)?")[^>]*(?:\s(width|height)="(\d*(?:\.\d+)?)(?:px)?")[^>]*>/i; // eslint-disable-line max-len +export const SVG_SIZE = /]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i; // eslint-disable-line max-len /** * Constants that identify shapes, mainly to prevent `instanceof` calls. diff --git a/src/core/utils/index.js b/src/core/utils/index.js index 8ca64ce..20b559b 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -163,8 +163,8 @@ if (sizeMatch) { - size[sizeMatch[1]] = Math.round(parseFloat(sizeMatch[2])); - size[sizeMatch[3]] = Math.round(parseFloat(sizeMatch[4])); + size[sizeMatch[1]] = Math.round(parseFloat(sizeMatch[3])); + size[sizeMatch[5]] = Math.round(parseFloat(sizeMatch[7])); } return size; diff --git a/test/core/util.js b/test/core/util.js index c5d7f9d..45d424a 100755 --- a/test/core/util.js +++ b/test/core/util.js @@ -195,6 +195,18 @@ .to.equal(32); }); + it('should return a size object from an SVG string with inverted quotes', function () + { + var svgSize = PIXI.utils.getSvgSize(""); // eslint-disable-line quotes + + expect(svgSize) + .to.be.an('object'); + expect(svgSize.width) + .to.equal(64); + expect(svgSize.height) + .to.equal(32); + }); + it('should work with px values', function () { var svgSize = PIXI.utils.getSvgSize('');