Skip to content

Commit 457e53a

Browse files
jfabrerodneyrehm
authored andcommitted
fix(polyfill): do not consider URLs viable values for running the polyfill. (#78)
I actually got a bug with background-image property pointing to cloudfront with this url: https://d3r0d0kb2vhuxd.cloudfront.net The viewportUnitExpression regex matched the url and the url got rewritten. This is a fix to avoid that.
1 parent c88ccc9 commit 457e53a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

viewport-units-buggyfill.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
var options;
2828
var userAgent = window.navigator.userAgent;
2929
var viewportUnitExpression = /([+-]?[0-9.]+)(vh|vw|vmin|vmax)/g;
30+
var urlExpression = /(https?:)?\/\//
3031
var forEach = [].forEach;
3132
var dimensions;
3233
var declarations;
@@ -261,7 +262,7 @@
261262
}
262263

263264
viewportUnitExpression.lastIndex = 0;
264-
if (viewportUnitExpression.test(value)) {
265+
if (viewportUnitExpression.test(value) && !urlExpression.test(value)) {
265266
// KeyframesRule does not have a CSS-PropertyName
266267
declarations.push([rule, null, value]);
267268
options.hacks && options.hacks.findDeclarations(declarations, rule, null, value);

0 commit comments

Comments
 (0)