Skip to content

Commit

Permalink
[TIMOB-6426] Removing strictMode on uri parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindelusions committed Dec 3, 2011
1 parent a622d98 commit 43764ed
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions mobileweb/src/Ti.Platform/platform.js
Expand Up @@ -143,16 +143,24 @@
}
};

_canOpenURL.options.strictMode = true;

// Methods
api.canOpenURL = function(url){
// Lots of stuff going on here. Basically we want to match any protocol urls ie: http, ftp, etc.
// including urls without a specified protocol ie: www.test.com, sub.domain.com, test.com, etc.
// and pass on any internal process urls ie: mailto, sms, tel, etc.
// Sometime in the future, we'd like to replace this with platform specific tests for valid urls
return /^(\w*:\/\/|[\w\d-]+^:[\w\d]+|[\w\d]+[\.@][\w\d]+)/.test(url);
};
api.canOpenURL = function(url){
// quickly cover the protocols we know how to handle
if (/^(https?|ftp|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/.test(url)) {
return true;
}
if (/^([tel|sms|mailto])/.test(url)) { return false; }

// if none of the above, parse the uri and use the parts to determine how its handled.
// this is how we'll deal with custom url schemes ie: my-app:someappname'
var uri = _canOpenURL(url);
if (typeof uri !== "object") {return true;}
if (uri.protocol === "") {
return true;
} else {
return /^([\/?#]|[\w\d-]+^:[\w\d]+^@)/.test(uri.protocol);
}
};
api.createUUID = function(){
return Ti._5.createUUID();
};
Expand Down

1 comment on commit 43764ed

@Mindelusions
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.