Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
CB-6730: Tweak whitelist URI parsing to fix
whitelist issues with @2x resource naming
  • Loading branch information
Rowell Cruz committed May 21, 2014
1 parent 520d01e commit b128ad7c6dcf0061c8616ba3e145c07faeaa8e02
Showing 2 changed files with 15 additions and 1 deletion.
@@ -366,7 +366,7 @@ self = module.exports = {
parseUri : function (str) {
var i, uri = {},
key = [ "source", "scheme", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor" ],
matcher = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(str);
matcher = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@\/]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(str);

for (i = key.length - 1; i >= 0; i--) {
uri[key[i]] = matcher[i] || "";
@@ -453,6 +453,20 @@ describe("whitelist", function () {
expect(whitelist.isFeatureAllowed("http://google.com/folder", "blackberry.media.camera")).toEqual(true);
});

it("can allow access to whitelisted HTTP URLs with @2x in the file name", function () {
var whitelist = new Whitelist({
hasMultiAccess : false,
accessList : [{
uri : "http://google.com",
allowSubDomain : true,
features : null
}]
});

expect(whitelist.isAccessAllowed("http://www.google.com/image@2x.png")).toEqual(true);
expect(whitelist.isAccessAllowed("http://www.cnn.com/image@2x.png")).toEqual(false);
});

describe("when access uris have subdomains", function () {
it("can get whitelisted features for subdomains", function () {
var whitelist = new Whitelist({

0 comments on commit b128ad7

Please sign in to comment.