gitxelectron 1.3.6 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/main/index.js
CHANGED
|
@@ -384,12 +384,13 @@ async function createGitHubRepository(sessionId, name, description, isPrivate, a
|
|
|
384
384
|
return await res.json();
|
|
385
385
|
}
|
|
386
386
|
function parseGithubUrl(remoteUrl) {
|
|
387
|
-
|
|
388
|
-
|
|
387
|
+
const url = remoteUrl.trim();
|
|
388
|
+
if (!url.includes("github.com")) throw new Error("Not a GitHub repository");
|
|
389
|
+
let parts = url.split("github.com");
|
|
389
390
|
let pathPart = parts[1].replace(/^[:\/]/, "").replace(/\.git$/, "");
|
|
390
391
|
const pathSplits = pathPart.split("/");
|
|
391
392
|
if (pathSplits.length >= 2) {
|
|
392
|
-
return { owner: pathSplits[0], repo: pathSplits[1] };
|
|
393
|
+
return { owner: pathSplits[0].trim(), repo: pathSplits[1].trim() };
|
|
393
394
|
}
|
|
394
395
|
throw new Error("Invalid GitHub repository URL");
|
|
395
396
|
}
|
|
@@ -402,10 +403,18 @@ async function getCollaborators(sessionId, remoteUrl) {
|
|
|
402
403
|
Accept: "application/vnd.github.v3+json",
|
|
403
404
|
"User-Agent": "gitelectron-App"
|
|
404
405
|
};
|
|
406
|
+
const safeFetch = async (url) => {
|
|
407
|
+
try {
|
|
408
|
+
return await fetch(url, { headers });
|
|
409
|
+
} catch (e) {
|
|
410
|
+
console.error(`Fetch failed for ${url}:`, e.message);
|
|
411
|
+
return { ok: false, json: async () => ({ message: e.message || "Network error" }) };
|
|
412
|
+
}
|
|
413
|
+
};
|
|
405
414
|
const [collabRes, invRes, contribRes] = await Promise.all([
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
415
|
+
safeFetch(`https://api.github.com/repos/${owner}/${repo}/collaborators`),
|
|
416
|
+
safeFetch(`https://api.github.com/repos/${owner}/${repo}/invitations`),
|
|
417
|
+
safeFetch(`https://api.github.com/repos/${owner}/${repo}/contributors`)
|
|
409
418
|
]);
|
|
410
419
|
if (!collabRes.ok) {
|
|
411
420
|
const errorData = await collabRes.json().catch(() => ({}));
|