mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
FIX: Validate asset url before replacing base url (#16438)
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
This commit is contained in:
parent
cd55d72b61
commit
0a8387ecd2
@ -38,7 +38,7 @@ export function getURLWithCDN(url) {
|
||||
// only relative urls
|
||||
if (cdn && /^\/[^\/]/.test(url)) {
|
||||
url = cdn + url;
|
||||
} else if (S3CDN) {
|
||||
} else if (S3CDN && url.startsWith(S3BaseUrl)) {
|
||||
url = url.replace(S3BaseUrl, S3CDN);
|
||||
}
|
||||
return url;
|
||||
|
@ -172,4 +172,12 @@ module("Unit | Utility | get-url", function () {
|
||||
|
||||
assert.strictEqual(getURLWithCDN(url), expected, "at correct path");
|
||||
});
|
||||
|
||||
test("getURLWithCDN when URL includes protocol", function (assert) {
|
||||
setupS3CDN("//awesome.cdn/site", "https://awesome.cdn/site");
|
||||
|
||||
let url = "https://awesome.cdn/site/awesome.png";
|
||||
|
||||
assert.strictEqual(getURLWithCDN(url), url, "at correct path");
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user