revdeck 0.2.3 → 0.3.1

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/dist/daemon.js CHANGED
@@ -543,6 +543,7 @@ var init_gitlab = __esm({
543
543
  sourceBranch: String(mr.source_branch ?? ""),
544
544
  targetBranch: String(mr.target_branch ?? ""),
545
545
  webUrl: String(mr.web_url ?? ""),
546
+ ...typeof mr.project_id === "number" ? { projectId: mr.project_id } : {},
546
547
  commit: { base, start, head },
547
548
  updatedAt: String(mr.updated_at ?? ""),
548
549
  stats: { files: Number.isFinite(files) ? files : 0, additions: 0, deletions: 0 }
@@ -691,7 +692,8 @@ rename to ${newPath}
691
692
  const uploaded = await this.json(["--method", "POST", endpoint, "--form", `file=@${input.path}`]);
692
693
  const raw = uploaded.full_path || uploaded.url || "";
693
694
  if (!raw) throw new ProviderError(tr("GitLab \u043D\u0435 \u0432\u0435\u0440\u043D\u0443\u043B \u0441\u0441\u044B\u043B\u043A\u0443 \u043D\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0439 \u0444\u0430\u0439\u043B", "GitLab did not return a link to the uploaded file"));
694
- const absolute = raw.startsWith("http://") || raw.startsWith("https://") ? raw : `https://${this.ref.host}${raw.startsWith("/") ? "" : "/"}${raw}`;
695
+ const projectId = (await this.info().catch(() => null))?.projectId;
696
+ const absolute = raw.startsWith("http://") || raw.startsWith("https://") ? raw : raw.startsWith("/uploads/") && projectId ? `https://${this.ref.host}/-/project/${projectId}${raw}` : `https://${this.ref.host}${raw.startsWith("/") ? "" : "/"}${raw}`;
695
697
  const label = input.name.replace(/[[\]\r\n]/g, " ").trim() || "attachment";
696
698
  const markdown = input.contentType.startsWith("image/") || input.contentType.startsWith("video/") ? `![${label}](${absolute})` : `[${label}](${absolute})`;
697
699
  return { name: input.name, url: absolute, markdown };
@@ -1165,7 +1167,7 @@ async function writeFileAtomic(file, data, mode = 384) {
1165
1167
  init_redact();
1166
1168
 
1167
1169
  // src/version.ts
1168
- var VERSION = "0.2.3";
1170
+ var VERSION = "0.3.1";
1169
1171
  var PROTOCOL_VERSION = 1;
1170
1172
 
1171
1173
  // src/daemon/main.ts
@@ -2134,12 +2136,11 @@ function imageIssue(text2, host) {
2134
2136
  }
2135
2137
  return null;
2136
2138
  }
2137
- function normalizeMediaLinks(body, platform, host) {
2138
- if (platform !== "gitlab" || !host) return body;
2139
- const base = `https://${host}`;
2140
- return body.replace(/(!?\[[^\]]*\]\(\s*)(\/?uploads\/[^)\s]+)/g, (_match, prefix, path9) => {
2141
- return `${prefix}${path9.startsWith("/") ? base : `${base}/`}${path9}`;
2142
- });
2139
+ function normalizeMediaLinks(body, platform, host, projectId) {
2140
+ if (platform !== "gitlab" || !host || !projectId) return body;
2141
+ const escaped = host.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2142
+ const correct = `https://${host}/-/project/${projectId}/uploads/`;
2143
+ return body.replace(new RegExp(`https?://${escaped}/uploads/`, "g"), correct).replace(new RegExp(`https?://${escaped}/-/project/\\d+/uploads/`, "g"), correct);
2143
2144
  }
2144
2145
 
2145
2146
  // src/core/attachments.ts
@@ -2922,8 +2923,8 @@ ${errors.join("\n")}`));
2922
2923
  continue;
2923
2924
  }
2924
2925
  const rawBody = draft.body.trim();
2925
- const body2 = normalizeMediaLinks(rawBody, review.info.ref.platform, review.info.ref.host);
2926
- const posted = normalizeMediaLinks(draft.posted.trim(), review.info.ref.platform, review.info.ref.host);
2926
+ const body2 = normalizeMediaLinks(rawBody, review.info.ref.platform, review.info.ref.host, review.info.projectId);
2927
+ const posted = normalizeMediaLinks(draft.posted.trim(), review.info.ref.platform, review.info.ref.host, review.info.projectId);
2927
2928
  const alreadyPosted = rawBody !== "" && posted === body2;
2928
2929
  const resolveChanged = draft.resolve !== thread.resolved;
2929
2930
  if (!body2 && !resolveChanged) {
@@ -2954,7 +2955,7 @@ ${errors.join("\n")}`));
2954
2955
  warnings.push(tr(`\u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0435 ${finding.id} \u0443\u0436\u0435 \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D\u043E`, `finding ${finding.id} is already published`));
2955
2956
  continue;
2956
2957
  }
2957
- const body2 = normalizeMediaLinks(finding.comment.trim(), review.info.ref.platform, review.info.ref.host);
2958
+ const body2 = normalizeMediaLinks(finding.comment.trim(), review.info.ref.platform, review.info.ref.host, review.info.projectId);
2958
2959
  const check2 = sanitizeBody(body2, review.info.ref.platform, { host: review.info.ref.host });
2959
2960
  if (!check2.ok) {
2960
2961
  warnings.push(tr(`\u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0435 ${finding.id}: ${check2.reason}`, `finding ${finding.id}: ${check2.reason}`));
@@ -2980,7 +2981,7 @@ ${errors.join("\n")}`));
2980
2981
  warnings.push(tr(`\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439 ${note.id} \u0443\u0436\u0435 \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D`, `comment ${note.id} is already published`));
2981
2982
  continue;
2982
2983
  }
2983
- const body = normalizeMediaLinks(note.text, review.info.ref.platform, review.info.ref.host);
2984
+ const body = normalizeMediaLinks(note.text, review.info.ref.platform, review.info.ref.host, review.info.projectId);
2984
2985
  const check = sanitizeBody(body, review.info.ref.platform, { host: review.info.ref.host });
2985
2986
  if (!check.ok) {
2986
2987
  warnings.push(tr(`\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439 ${note.id}: ${check.reason}`, `comment ${note.id}: ${check.reason}`));