Skip to content

Commit

Permalink
chore(): refactor to urijs instead of url-parse
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Apr 7, 2016
1 parent 4ea8dfe commit 1d4742c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"shelljs": "^0.6.0",
"style-loader": "^0.13.0",
"url-loader": "^0.5.7",
"url-parse": "^1.0.5",
"webpack": "^1.12.14",
"xcode": "^0.8.4",
"xmldom": "^0.1.22",
Expand Down
17 changes: 9 additions & 8 deletions src/app/settings/SettingsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

var angular = require('angular'),
Server = require('../servers/models/Server'),
URL = require('url-parse');
URI = require('urijs');

require('../availability/AvailabilityService');
require('../servers/Servers');
Expand Down Expand Up @@ -66,7 +66,7 @@

var tryServer = function(s) {
var server = new Server(s);
var url = new URL(server.url);
var url = new URI(server.url);
var urls = [];

var tryUrl = function(url) {
Expand All @@ -93,8 +93,9 @@
});
};

if (!url.pathname.endsWith('/')) {
url.set('pathname', url.pathname + '/');

if (!url.pathname().endsWith('/')) {
url.pathname(url.pathname() + '/');
}
server.url = url.toString();

Expand All @@ -120,18 +121,18 @@
return tryUrl(server.url).catch(function(err) {
updateError(err);
// then, try with /opennms/ appended
url.set('pathname', url.pathname + 'opennms/');
url.pathname(url.pathname() + 'opennms/');
return tryUrl(url.toString());
}).catch(function(err) {
updateError(err);
// then, try toggling SSL
url = new URL(server.url);
url.set('protocol', url.protocol === 'http:'? 'https:':'http:');
url = new URI(server.url);
url.protocol(url.protocol() == 'http'? 'https':'http');
return tryUrl(url.toString());
}).catch(function(err) {
updateError(err);
// then, try the toggled with /opennms/ appended
url.set('pathname', url.pathname + 'opennms/');
url.pathname(url.pathname() + 'opennms/');
return tryUrl(url.toString());
}).catch(function(err) {
updateError(err);
Expand Down

0 comments on commit 1d4742c

Please sign in to comment.