mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 11:48:08 +08:00
FIX: Image file names with dots were showing incorrectly in composer markdown (#8465)
When uploading an image file with dots in the filename we were splitting the string on dots and getting the last of the split items as the extension-less filename. However this did not work with filenames that have dots. We now just remove the extension using substr.
This commit is contained in:
@ -7,8 +7,7 @@ function isGUID(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function imageNameFromFileName(fileName) {
|
function imageNameFromFileName(fileName) {
|
||||||
const split = fileName.split(".");
|
let name = fileName.substr(0, fileName.lastIndexOf("."));
|
||||||
let name = split[split.length - 2];
|
|
||||||
|
|
||||||
if (isAppleDevice() && isGUID(name)) {
|
if (isAppleDevice() && isGUID(name)) {
|
||||||
name = I18n.t("upload_selector.default_image_alt_text");
|
name = I18n.t("upload_selector.default_image_alt_text");
|
||||||
|
@ -205,6 +205,11 @@ QUnit.test("getUploadMarkdown", assert => {
|
|||||||
""
|
""
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
testUploadMarkdown("image.file.name.with.dots.png"),
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
const short_url = "uploads://asdaasd.ext";
|
const short_url = "uploads://asdaasd.ext";
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
@ -213,15 +218,18 @@ QUnit.test("getUploadMarkdown", assert => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("replaces GUID in image alt text on iOS", assert => {
|
QUnit.test(
|
||||||
assert.equal(
|
"getUploadMarkdown - replaces GUID in image alt text on iOS",
|
||||||
testUploadMarkdown("8F2B469B-6B2C-4213-BC68-57B4876365A0.jpeg"),
|
assert => {
|
||||||
""
|
assert.equal(
|
||||||
);
|
testUploadMarkdown("8F2B469B-6B2C-4213-BC68-57B4876365A0.jpeg"),
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
sandbox.stub(Utilities, "isAppleDevice").returns(true);
|
sandbox.stub(Utilities, "isAppleDevice").returns(true);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
testUploadMarkdown("8F2B469B-6B2C-4213-BC68-57B4876365A0.jpeg"),
|
testUploadMarkdown("8F2B469B-6B2C-4213-BC68-57B4876365A0.jpeg"),
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
Reference in New Issue
Block a user