#13 Finializing fix

- Updated the regex to double exclude '\'
- Updated extractValue function to return the full result
This commit is contained in:
Logan Cusano
2024-03-09 17:22:52 -05:00
parent 6ab0ec6d6f
commit 73da7ee2f4
2 changed files with 4 additions and 4 deletions

View File

@@ -11,8 +11,8 @@ let type = "dshow";
if (os.platform() === 'linux') { if (os.platform() === 'linux') {
await new Promise((res) => { await new Promise((res) => {
executeCommand("pactl", ['list', 'short', 'sources']).then(cliOutput => { executeCommand("pactl", ['list', 'short', 'sources']).then(cliOutput => {
device = extractValue(cliOutput, '(?:\d[ ]{4,12}(.+?)[ ]{4,12}(?:.+?[ ]{4,12}){2,4}RUNNING)') device = extractValue(cliOutput, '(?:\\d(?:\\t|[\\s]{1,9})(?<device>[\\w\\d\\-\\.\\_]+?)(?:\\t|[\\s]{1,9})(?<card>[\\w\\d\\-\\.\\_]+)(?:\\t|[\\s]{1,9})(?:(?<device_type>[\\w\\d\\-\\.\\_]+?) (?<channels>\\dch) (?<frequency>\\d+Hz))(?:\\t|[\\s]{1,9})(?:IDLE|RUNNING|SUSPENDED))')
console.log("Device:", device); console.log("Device:", device.groups.device);
res(); res();
}); });
}); });

View File

@@ -71,7 +71,7 @@ export const generateUniqueID = () => {
* @returns {string|null} The value found after the pattern, or null if not found. * @returns {string|null} The value found after the pattern, or null if not found.
*/ */
export const extractValue = (input, pattern) => { export const extractValue = (input, pattern) => {
const regex = new RegExp(`${pattern}\\s+(\\S+)`); const regex = new RegExp(`${pattern}`);
const match = input.match(regex); const match = input.match(regex);
return match ? match[1] : null; return match ? match : null;
}; };