azdo-cli 0.5.0-032-fix-code-generics.567 → 0.5.0-032-fix-code-generics.570

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.
Files changed (2) hide show
  1. package/dist/index.js +25 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1230,14 +1230,34 @@ function isHtml(content) {
1230
1230
  }
1231
1231
 
1232
1232
  // src/services/md-convert.ts
1233
+ var PLT = "@@PLT@@";
1234
+ var PGT = "@@PGT@@";
1235
+ function escapeAnglesInCodeElements(html) {
1236
+ return html.replace(/<code([^>]*)>([\s\S]*?)<\/code>/gi, (_, attrs, content) => {
1237
+ const safe = content.split("&lt;").join(PLT).split("&gt;").join(PGT).replace(/</g, "&lt;").replace(/>/g, "&gt;").split(PLT).join("&lt;").split(PGT).join("&gt;");
1238
+ return `<code${attrs}>${safe}</code>`;
1239
+ });
1240
+ }
1241
+ function escapeAnglesInMarkdownCodeSpans(markdown) {
1242
+ return markdown.replace(/(?<!`)`([^`\n]+)`(?!`)/g, (_, inner) => {
1243
+ const safe = inner.split("&lt;").join(PLT).split("&gt;").join(PGT).replace(/</g, "&lt;").replace(/>/g, "&gt;").split(PLT).join("&lt;").split(PGT).join("&gt;");
1244
+ return "`" + safe + "`";
1245
+ });
1246
+ }
1247
+ function decodeEntitiesInMarkdownCodeSpans(text) {
1248
+ return text.replace(/(?<!`)`([^`\n]+)`(?!`)/g, (_, inner) => {
1249
+ const decoded = inner.replace(/&lt;/g, "<").replace(/&gt;/g, ">");
1250
+ return "`" + decoded + "`";
1251
+ });
1252
+ }
1233
1253
  function htmlToMarkdown(html) {
1234
- return NodeHtmlMarkdown.translate(html);
1254
+ return NodeHtmlMarkdown.translate(escapeAnglesInCodeElements(html));
1235
1255
  }
1236
1256
  function toMarkdown(content) {
1237
1257
  if (isHtml(content)) {
1238
1258
  return htmlToMarkdown(content);
1239
1259
  }
1240
- return content;
1260
+ return decodeEntitiesInMarkdownCodeSpans(content);
1241
1261
  }
1242
1262
 
1243
1263
  // src/services/command-helpers.ts
@@ -2675,8 +2695,9 @@ function createSetMdFieldCommand() {
2675
2695
  try {
2676
2696
  context = resolveContext(options);
2677
2697
  const credential = await requireAuthCredential(context.org);
2698
+ const safeContent = escapeAnglesInMarkdownCodeSpans(content);
2678
2699
  const operations = [
2679
- { op: "add", path: `/fields/${field}`, value: content },
2700
+ { op: "add", path: `/fields/${field}`, value: safeContent },
2680
2701
  { op: "add", path: `/multilineFieldsFormat/${field}`, value: "Markdown" }
2681
2702
  ];
2682
2703
  const result = await updateWorkItem(context, id, credential, field, operations);
@@ -5075,7 +5096,7 @@ async function addWorkItemRelation(context, cred, type, id1, id2) {
5075
5096
  const workItem = await getWorkItemWithRelations(context, cred, id1);
5076
5097
  const targetUrl = `https://dev.azure.com/${encodeURIComponent(context.org)}/_apis/wit/workItems/${id2}`;
5077
5098
  const existing = (workItem.relations ?? []).find(
5078
- (r) => r.rel === relType.referenceName && r.url.toLowerCase() === targetUrl.toLowerCase()
5099
+ (r) => r.rel === relType.referenceName && parseTargetId(r.url) === id2
5079
5100
  );
5080
5101
  if (existing) {
5081
5102
  return { status: "already_exists", type: relType.name, referenceName: relType.referenceName, id1, id2 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azdo-cli",
3
- "version": "0.5.0-032-fix-code-generics.567",
3
+ "version": "0.5.0-032-fix-code-generics.570",
4
4
  "description": "Azure DevOps CLI tool",
5
5
  "type": "module",
6
6
  "bin": {