appcelerator/titanium_mobile — pull request #838 by Mindelusions (2011-12-05 16:39:39+00:00)
Title: [Timob-6426] Fix for Platform openURL() and canOpenURL() methods

app.js:

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');

var testUris = [
["http:"],
["https://"],
["http://host"],
["http://host/"],
["http://host.com"],
["http://subdomain.host.com"],
["http://host.com:81"],
["http://user@host.com"],
["http://user@host.com:81"],
["http://user:@host.com"],
["http://user:@host.com:81"],
["http://user:pass@host.com"],
["http://user:pass@host.com:81"],
["http://user:pass@host.com:81?query"],
["http://user:pass@host.com:81#anchor"],
["http://user:pass@host.com:81/"],
["http://user:pass@host.com:81/?query"],
["http://user:pass@host.com:81/#anchor"],
["http://user:pass@host.com:81/file.ext"],
["http://user:pass@host.com:81/directory"],
["http://user:pass@host.com:81/directory?query"],
["http://user:pass@host.com:81/directory#anchor"],
["http://user:pass@host.com:81/directory/"],
["http://user:pass@host.com:81/directory/?query"],
["http://user:pass@host.com:81/directory/#anchor"],
["http://user:pass@host.com:81/directory/sub.directory/"],
["http://user:pass@host.com:81/directory/sub.directory/file.ext"],
["http://user:pass@host.com:81/directory/file.ext?query"],
["http://user:pass@host.com:81/directory/file.ext?query=1&test=2"],
["http://user:pass@host.com:81/directory/file.ext?query=1#anchor"],
["//host.com"],
["//user:pass@host.com:81/direc.tory/file.ext?query=1&test=2#anchor"],
["/directory/sub.directory/file.ext?query=1&test=2#anchor"],
["/directory/"],
["/file.ext"],
["/?query"],
["/#anchor"],
["/"],
["?query"],
["?query=1&test=2#anchor"],
["#anchor"],
["path/to/file"],
["localhost"],
["192.168.1.1"],
["host.com"],
["user@host.com/file.ext"],
["user@host.com?query"],
["user@host.com#anchor"],
["user:pass@host.com:81/direc.tory/file.ext?query=1&test=2#anchor"],
["http://test.com"],
["www.test.com"],
["mailto:you@test.com"],
["tel:18007751234"],
["my-app:go/here/please"],
["localhost:80"],
["192.168.1.220:8080"],
["ftp://static.test.com"],
["sms:17028798649"],
["itms:someurl.com/some/place"],
["itms-app:com.someapp/path"]
], i = 0, len = testUris.length, label = null;

var win = Ti.UI.createWindow({
title:'Platform openURL()',
backgroundColor:'#fff'
});

for ( ; i