mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-10 03:13:32 -07:00
feat(aniskip): move intro detection from mpv plugin to app runtime (#117)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
function sanitizeScriptOptValue(value: string): string {
|
||||
return value
|
||||
.replace(/,/g, ' ')
|
||||
.replace(/[\r\n]/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
}
|
||||
|
||||
function assertScriptOptPathValue(name: string, value: string): void {
|
||||
if (/[,\r\n]/.test(value)) {
|
||||
throw new Error(`${name} contains unsupported script option delimiter`);
|
||||
}
|
||||
}
|
||||
|
||||
export function buildSubminerScriptOpts(
|
||||
appPath: string,
|
||||
socketPath: string,
|
||||
extraParts: string[] = [],
|
||||
): string {
|
||||
const hasBinaryPath = extraParts.some((part) => part.startsWith('subminer-binary_path='));
|
||||
const hasSocketPath = extraParts.some((part) => part.startsWith('subminer-socket_path='));
|
||||
if (!hasBinaryPath) {
|
||||
assertScriptOptPathValue('subminer-binary_path', appPath);
|
||||
}
|
||||
if (!hasSocketPath) {
|
||||
assertScriptOptPathValue('subminer-socket_path', socketPath);
|
||||
}
|
||||
const parts = [
|
||||
...(hasBinaryPath ? [] : [`subminer-binary_path=${appPath}`]),
|
||||
...(hasSocketPath ? [] : [`subminer-socket_path=${socketPath}`]),
|
||||
...extraParts.map(sanitizeScriptOptValue),
|
||||
];
|
||||
return parts.join(',');
|
||||
}
|
||||
Reference in New Issue
Block a user