This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/cook-text.js.es6
Martin Brennan 3e54e0191e
FIX: Use full URL for secure attachments when secure media enabled (#9037)
When secure media is enabled and an attachment is marked as secure we want to use the full url instead of the short-url so we get the same access control post protections as secure media uploads.
2020-03-04 10:11:08 +11:00

28 lines
714 B
JavaScript

import { next } from "@ember/runloop";
import Component from "@ember/component";
import { cookAsync } from "discourse/lib/text";
import { ajax } from "discourse/lib/ajax";
const CookText = Component.extend({
tagName: "",
cooked: null,
didReceiveAttrs() {
this._super(...arguments);
cookAsync(this.rawText).then(cooked => {
this.set("cooked", cooked);
// no choice but to defer this cause
// pretty text may only be loaded now
next(() =>
window
.requireModule("pretty-text/upload-short-url")
.resolveAllShortUrls(ajax, this.siteSettings)
);
});
}
});
CookText.reopenClass({ positionalParams: ["rawText"] });
export default CookText;