Validate beef.net.connection.type value

This commit is contained in:
Brendan Coles
2015-12-13 21:43:29 +00:00
parent 06e9c6024b
commit cb4df3a72c

View File

@@ -18,7 +18,7 @@ beef.net.connection = {
try { try {
var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
var type = connection.type; var type = connection.type;
if (type) return type; else return 'unknown'; if (/^[a-z]+$/.test(type)) return type; else return 'unknown';
} catch(e) { } catch(e) {
beef.debug("Error retrieving connection type: " + e.message); beef.debug("Error retrieving connection type: " + e.message);
return 'unknown'; return 'unknown';