diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index 3de5ff153593420e9e3d5c1e7a7d1d4331622c0f..ce2ee21ff7fdb1d54ff0347450deb11a3050d857 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -541,7 +541,7 @@ function WotLookupController($scope, $state, $q, $timeout, $focus, $location, $i return; } BMA.uri.parse(result) - .then(function(obj){ + .then(function(obj) { if (obj.pubkey) { $scope.search.text = obj.pubkey; } diff --git a/www/js/services/bma-services.js b/www/js/services/bma-services.js index 5ec007678dfd86ee279e65f20c849d7f2cea742a..565e53adb95d2eea7315a10f3c33421fa3668a4a 100644 --- a/www/js/services/bma-services.js +++ b/www/js/services/bma-services.js @@ -1016,14 +1016,14 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. } // Uid - else if (uri.startsWith('@') && exports.regexp.USER_ID.test(uid.substr(1))) { + else if (uri.startsWith('@') && exports.regexp.USER_ID.test(uid.substring(1))) { resolve({ - uid: uid.substr(1) + uid: uid.substring(1) }); } // G1 protocols - else if(uri.startsWith('june:') || uri.startsWith('web+june:')) { + else if (uri.startsWith('june:') || uri.startsWith('web+june:')) { var parser = csHttp.uri.parse(uri); // Pubkey (explicit path) @@ -1052,9 +1052,9 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. } // UID - else if (parser.hostname && parser.hostname.startsWith('@') && exports.regexp.USER_ID.test(parser.hostname.substr(1))) { + else if (parser.hostname && parser.hostname.startsWith('@') && exports.regexp.USER_ID.test(parser.hostname.substring(1))) { resolve({ - uid: parser.hostname.substr(1), + uid: parser.hostname.substring(1), pathSegments: parser.pathSegments, params: parser.searchParams }); @@ -1088,12 +1088,14 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. // Validate checksum if (result.pubkey && exports.regexp.PUBKEY_WITH_CHECKSUM.test(result.pubkey)) { console.debug("[BMA.parse] Validating pubkey checksum... "); - var matches = exports.regexp.PUBKEY_WITH_CHECKSUM.exec(uri); + var matches = exports.regexp.PUBKEY_WITH_CHECKSUM.exec(result.pubkey); pubkey = matches[1]; var checksum = matches[2]; var expectedChecksum = csCrypto.util.pkChecksum(pubkey); if (checksum !== expectedChecksum) { - console.warn("[BMA.parse] Detecting a pubkey {"+pubkey+"} with checksum {" + checksum + "}, but expecting checksum is {" + expectedChecksum + "}"); + console.warn("[BMA.parse] Detecting a pubkey {{0}} with checksum {{1}}, but expecting checksum is {{2}}".format( + pubkey, checksum, expectedChecksum + )); throw {message: 'ERROR.PUBKEY_INVALID_CHECKSUM'}; } result.pubkey = pubkey; diff --git a/www/js/services/device-services.js b/www/js/services/device-services.js index 9be7c7821907bcb22341919b014bf280c421b0b1..4681bb12634ba163e8fd42c78fd498d4ceb5a901 100644 --- a/www/js/services/device-services.js +++ b/www/js/services/device-services.js @@ -88,7 +88,7 @@ angular.module('cesium.device.services', ['cesium.utils.services', 'cesium.setti } function scan(n) { - if (!exports.enable) { + if (!exports.barcode.enable) { return $q.reject("Barcode scanner not enable. Please call 'ionicReady()' once before use (e.g in app.js)."); } var deferred = $q.defer(); diff --git a/www/js/services/http-services.js b/www/js/services/http-services.js index 1ccd538cbacb98deca8b80fef954ac444aff409c..22463b5fbc3f9a0585135a69abc33e5a0f214032 100644 --- a/www/js/services/http-services.js +++ b/www/js/services/http-services.js @@ -371,6 +371,19 @@ angular.module('cesium.http.services', ['cesium.cache.services']) if (hostname.indexOf('?') !== -1) { hostname = hostname.substr(0, path.indexOf('?')); } + + if (hostname.indexOf(':') !== -1) { + var port = hostname.substring(path.indexOf(':')+1); + var cleanHostName = hostname.substr(0, path.indexOf(':')); + // Invalid port (e.g. a checksum) => remove it (otherwise net <a> parser will failed to parse the URI) + if (isNaN(parseInt(port))) { + path = cleanHostName + path.substring(hostname.length); + } + else { + hostname = cleanHostName; + } + } + // Clean path uri = 'http://' + path; }