chore(go): audit shared plugin helpers
Drop unused expandHome and standardizeJSONC, share the runtime base URL validator between the guard and audit templates, and trim comments. Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
This commit is contained in:
1 parent
5e08ab20f5
commit
b085947547
9 files changed
+42
-102
No files matched your search
@@ -146,30 +146,8 @@ function writeStatusCache(status) {
|
||||
});
|
||||
}
|
||||
|
||||
function resolveBaseURL(config) {
|
||||
const value = config.base_url || 'https://api.elydora.com';
|
||||
if (typeof value !== 'string' || /[\\\u0000-\u0020]/.test(value)) {
|
||||
throw new Error('Agent config base_url must be an absolute HTTP or HTTPS URL');
|
||||
}
|
||||
let parsed;
|
||||
try {
|
||||
parsed = new URL(value);
|
||||
} catch (error) {
|
||||
throw new Error('Agent config base_url must be an absolute HTTP or HTTPS URL');
|
||||
}
|
||||
if (!['http:', 'https:'].includes(parsed.protocol) || !parsed.hostname) {
|
||||
throw new Error('Agent config base_url must be an absolute HTTP or HTTPS URL');
|
||||
}
|
||||
if (parsed.username || parsed.password || parsed.search || parsed.hash) {
|
||||
throw new Error(
|
||||
'Agent config base_url must exclude credentials, query parameters, and fragments',
|
||||
);
|
||||
}
|
||||
return value.replace(/\/+$/, '');
|
||||
}
|
||||
|
||||
async function resolveRemoteStatus(config) {
|
||||
const baseURL = resolveBaseURL(config);
|
||||
const baseURL = resolveConfigBaseURL(config);
|
||||
const token = config.token || '';
|
||||
if (typeof token !== 'string') throw new Error('Agent config token must be a string');
|
||||
const controller = new AbortController();
|
||||
|
||||
Reference in new issue
Block a user