Skip to content

Commit

Permalink
Makes sure that the property of a style is not an url
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jeremy-codescout committed Apr 10, 2017
1 parent 13ebe02 commit 39efeba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion viewport-units-buggyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
var options;
var userAgent = window.navigator.userAgent;
var viewportUnitExpression = /([+-]?[0-9.]+)(vh|vw|vmin|vmax)/g;
var url = /(https?:)?\/\//

var forEach = [].forEach;
var dimensions;
var declarations;
Expand Down Expand Up @@ -289,7 +291,7 @@
}

viewportUnitExpression.lastIndex = 0;
if (viewportUnitExpression.test(value)) {
if (viewportUnitExpression.test(value) && !url.test(value)) {
declarations.push([rule, name, value]);
options.hacks && options.hacks.findDeclarations(declarations, rule, name, value);
}
Expand Down

0 comments on commit 39efeba

Please sign in to comment.