Skip to content

Commit

Permalink
Fix selecting Plex uri for remote servers
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceK33z committed Dec 17, 2016
1 parent df57f91 commit 4a0a767
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ function getSections(url, plexToken) {
}

function getBestConnectionUrl(server) {
// First try to find a non-local (remote) connection to the server.
let conn = server.Connection.find((connection) => connection.local === '0');
if (conn) {
return conn.uri;
// `server.Connection` can be an array or object.
if (Array.isArray(server.Connection)) {
let conn = server.Connection.find((connection) => connection.local === '0');
if (conn) {
return conn.uri;
}
// If there are only local connections, fine then.
return conn[0].uri;
}
// If there are only local connections, fine then.
return conn[0].uri;
return server.Connection.uri;
}

function performTest() {
Expand Down

0 comments on commit 4a0a767

Please sign in to comment.