fix(skills): address Copilot review nits (safety + UI guards)
This commit is contained in:
@@ -91,6 +91,8 @@ export default function SkillsPacksPage() {
|
||||
};
|
||||
|
||||
const handleSyncPack = async (pack: SkillPackRead) => {
|
||||
if (syncingPackIds.has(pack.id)) return;
|
||||
|
||||
setSyncingPackIds((previous) => {
|
||||
const next = new Set(previous);
|
||||
next.add(pack.id);
|
||||
|
||||
@@ -9,7 +9,15 @@ export const repoBaseFromSkillSourceUrl = (skillSourceUrl: string): string | nul
|
||||
const marker = "/tree/";
|
||||
const markerIndex = parsed.pathname.indexOf(marker);
|
||||
if (markerIndex <= 0) return null;
|
||||
return normalizeRepoSourceUrl(`${parsed.origin}${parsed.pathname.slice(0, markerIndex)}`);
|
||||
|
||||
// Reject unexpected structures (e.g. multiple /tree/ markers).
|
||||
if (parsed.pathname.indexOf(marker, markerIndex + marker.length) !== -1) return null;
|
||||
|
||||
const repoPath = parsed.pathname.slice(0, markerIndex);
|
||||
if (!repoPath || repoPath === "/") return null;
|
||||
if (repoPath.endsWith("/tree")) return null;
|
||||
|
||||
return normalizeRepoSourceUrl(`${parsed.origin}${repoPath}`);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user