Skip to content

Commit

Permalink
Conditionally remove @uuid link labels on extract (foundryvtt#8041)
Browse files Browse the repository at this point in the history
Labels are removed when they are identical to their respective document names
  • Loading branch information
stwlam committed May 30, 2023
1 parent f587563 commit 8874082
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions build/lib/extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,10 @@ class PackExtractor {
return partiallyConverted;
}

const replacePattern = new RegExp(`(?<!"_?id":")${docId}(?=\\])`, "g");
return partiallyConverted.replace(replacePattern, docName);
const idPattern = new RegExp(`(?<!"_?id":")${docId}(?=\\])`, "g");
// Remove link labels when the label is the same as the document name
const labeledLinkPattern = new RegExp(String.raw`(@UUID\[[^\]]+\])\{${docName}\}`);
return partiallyConverted.replace(idPattern, docName).replace(labeledLinkPattern, "$1");
}, docJSON);

return JSON.parse(convertedJson) as PackEntry;
Expand Down

0 comments on commit 8874082

Please sign in to comment.