mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
33 lines
522 B
JavaScript
33 lines
522 B
JavaScript
/* eslint-disable camelcase -- cache index access */
|
|
|
|
/**
|
|
* If line is commented out or empty, return null.
|
|
* Otherwise, return trimmed line.
|
|
*
|
|
* @param {string} line
|
|
*/
|
|
module.exports.processLine = (line) => {
|
|
if (!line) {
|
|
return null;
|
|
}
|
|
|
|
const line_0 = line[0];
|
|
|
|
if (
|
|
line_0 === '#'
|
|
|| line_0 === ' '
|
|
|| line_0 === '\r'
|
|
|| line_0 === '\n'
|
|
|| line_0 === '!'
|
|
) {
|
|
return null;
|
|
}
|
|
|
|
const trimmed = line.trim();
|
|
if (trimmed === '') {
|
|
return null;
|
|
}
|
|
|
|
return trimmed;
|
|
};
|