mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 10:25:35 +08:00
FIX: Replace %20 with space in markdown file name for uploads (#8405)
Meta: https://meta.discourse.org/t/image-name-has-20-in-file-name/134136 We were ending up with [file%20name](url) in the markdown preview, which looked weird and affected the alt text. this is because we were calling encodeURIComponent, which has been left in place because this is a valid thing to do for some cases. (e.g. f674b9e)
This commit is contained in:
parent
afb5533581
commit
b89e634dd4
@ -14,7 +14,7 @@ function imageNameFromFileName(fileName) {
|
||||
name = I18n.t("upload_selector.default_image_alt_text");
|
||||
}
|
||||
|
||||
return encodeURIComponent(name);
|
||||
return encodeURIComponent(name).replace(/%20/g, " ");
|
||||
}
|
||||
|
||||
export function validateUploadedFiles(files, opts) {
|
||||
|
@ -200,6 +200,10 @@ QUnit.test("getUploadMarkdown", assert => {
|
||||
testUploadMarkdown("[foo|bar].png"),
|
||||
""
|
||||
);
|
||||
assert.equal(
|
||||
testUploadMarkdown("file name with space.png"),
|
||||
""
|
||||
);
|
||||
|
||||
const short_url = "uploads://asdaasd.ext";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user