Improve parser to ignore stanzas that are commented out or not formatted by this program.
This commit is contained in:
parent
bcc29424da
commit
5496881616
|
@ -23,19 +23,19 @@ function parseConfig (str) {
|
||||||
const lines = str.split('\n')
|
const lines = str.split('\n')
|
||||||
let network = {}
|
let network = {}
|
||||||
for (let line of lines) {
|
for (let line of lines) {
|
||||||
if (line.indexOf('network={') !== -1) {
|
if (line.substring(0, 9) === 'network={') {
|
||||||
network = {}
|
network = {}
|
||||||
network.raw = line
|
network.raw = line
|
||||||
} else if (line.indexOf('ssid=') !== -1) {
|
} else if (network.raw && line.indexOf('ssid=') !== -1) {
|
||||||
network.ssid = line.replace('ssid=', '').trim().replace(quoteRe, '')
|
network.ssid = line.replace('ssid=', '').trim().replace(quoteRe, '')
|
||||||
if (network.raw) {
|
if (network.raw) {
|
||||||
network.raw += '\n' + line
|
network.raw += '\n' + line
|
||||||
}
|
}
|
||||||
} else if (line.indexOf('}') !== -1) {
|
} else if (network.raw && line.substring(0, 1) === '}') {
|
||||||
network.raw += '\n' + line
|
network.raw += '\n' + line
|
||||||
networks.push(network)
|
networks.push(network)
|
||||||
network = {}
|
network = {}
|
||||||
} else if (network.ssid) {
|
} else if (network.raw) {
|
||||||
network.raw += '\n' + line
|
network.raw += '\n' + line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue