Skip to content

Commit

Permalink
Merge pull request #88 from Isopolito/87
Browse files Browse the repository at this point in the history
Fix problem of parsing country output
  • Loading branch information
Isopolito authored Mar 24, 2024
2 parents b2a097b + 4680b0e commit a4db519
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
],
"url": "https://github.com/Isopolito/gNordVPN-Local",
"uuid": "gnordvpn-local@isopolito",
"version": 25
"version": 26
}
10 changes: 5 additions & 5 deletions modules/Vpn.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ export default class Vpn {

// Remove the junk that shows up from messages in the nordvpn output
_processCityCountryOutput = (input) => {
const match = input.match(/(^\w+?,\s(\w+?,\s)+?(\w+?$)|^\s*?\w+?\s*?$)/gm);
return match && match.length === 1
? match[0].split(',').map(c => c.trim()).sort()
: [];
}
input = input.replace(/^[\W_]+/, ''); // Remove any leading junk
const countries = input.split(',').map(c => c.trim()); // Split and trim each country name
const validCountries = countries.filter(c => /\b\w[\w\s'-]*\b/.test(c)); // Keep valid country names
return validCountries.sort(); // Sort and return the valid country names
};

_getString = (data) => {
const decoder = new TextDecoder('utf-8');
Expand Down

0 comments on commit a4db519

Please sign in to comment.