Skip to content

Commit

Permalink
Add Uint8Array checking function
Browse files Browse the repository at this point in the history
  • Loading branch information
konkor committed Oct 13, 2019
1 parent effaada commit bf8221c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion convenience.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Soup = imports.gi.Soup;
const Gettext = imports.gettext;
const ByteArray = imports.byteArray;

var Format = imports.format;
String.prototype.format = Format.format;
Expand Down Expand Up @@ -250,7 +251,7 @@ function get_ip_addresses () {
let addresses = [];
var cmd_output = GLib.spawn_command_line_sync ('ip addr show');
if (!cmd_output[0]) return ['127.0.0.1'];
var list = cmd_output[1].toString ().split ('\n');
var list = byteArrayToString (cmd_output[1]).toString ().split ('\n');
list.forEach ((s)=>{
let ar;
if ((s.indexOf ('inet') > -1) && (s.indexOf ('scope global') > -1)) {
Expand All @@ -262,3 +263,7 @@ function get_ip_addresses () {
if (addresses.length == 0) addresses.push ('127.0.0.1');
return addresses;
}

function byteArrayToString (array) {
return array instanceof Uint8Array ? ByteArray.toString (array):array;
}

0 comments on commit bf8221c

Please sign in to comment.