Extend core for discourse-encrypt uploads (PR #8440)


You’ve signed the CLA, udan11. Thank you! This pull request is ready for review.

Maybe addComposerUploadMarkdownResolver ?

Also behavior when chained is a bit tricky, do we even want to allow chaining?

I think it could be interesting to have variables for each used match. eg: const foo = match[5]

This would make the whole code block much more readable.

if there’s any chance $upload.text() can be "" we should do:

            const content = $upload.text().split("|").filter(Boolean);

probably worth to have split[i] as a variable here as it’s reused multiple times.

if there’s any chance alt can be “” we should do:

  const split = alt.split("|").filter(Boolean);

This method should be tested

It will use the last “truthy” value returned by a resolver. This way it allows multiple plugins to work correctly as long as an upload is not of interest to multiple plugins (or they could still alter attributes of the upload object such as filename).

The problem is that some parts may have multiple meanings. An “accurate” name for match[5] would be widthOrHeightRatioOrPercentage, which is useless. Later, variables are defined to hold the value (for example for match[5] it is percent, wr or hr).

[double pipe ||]() should generate a link with title ‘double pipe ||’. If blank values would be filtered, then the output would be 'double pipe '.

Similar to the other place, it does not hold a specific value. It would have a generic name such as part or fragment which does not really add any value.

Alt texts can also contain ‘|’.

I agree. Added a test. :slight_smile:

  const contentSplit = [];
  if (contentSplit.length > 0) {
    textToken.content = contentSplit.join("|");
  const altSplit = [];
  token.attrs[token.attrIndex("alt")][1] = altSplit.join("|");