A platform for community discussion. Free, open, simple.
FIX: ensures auto grid works in german (#33831)
Joffrey JAFFEUXfd4c6897e2be
diff --git a/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.js b/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.jsindex e175438dae6..93d8cfe6657 100644--- a/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.js+++ b/app/assets/javascripts/discourse/app/lib/uppy/composer-upload.js@@ -633,7 +633,9 @@ export default class UppyComposerUpload {const uploadingText = i18n("uploading_filename", {filename: "%placeholder%",});- const uploadingTextMatch = uploadingText.match(/^.*(?=: %placeholder%…)/);+ const uploadingTextMatch = uploadingText.match(+ /^.*(?=: %placeholder%\s?…)/+ );if (!uploadingTextMatch || !uploadingTextMatch[0]) {return;@@ -642,7 +644,7 @@ export default class UppyComposerUpload {const uploadingImagePattern = new RegExp("\\[" +uploadingTextMatch[0].trim() +- "\\s?: ([^\\]]+?)\\.\\w+…\\]\\(\\)",+ "\\s?: ([^\\]]+?)\\.\\w+\\s?…\\]\\(\\)","g");@@ -656,7 +658,9 @@ export default class UppyComposerUpload {imagePlaceholder = imagePlaceholder.trim();const filenamePattern = new RegExp(- "\\[" + uploadingTextMatch[0].trim() + "\\s?: ([^\\]]+?)\\…\\]\\(\\)"+ "\\[" ++ uploadingTextMatch[0].trim() ++ "\\s?: ([^\\]]+?)\\s?\\…\\]\\(\\)");const filenameMatch = imagePlaceholder.match(filenamePattern);diff --git a/spec/system/composer_uploads_spec.rb b/spec/system/composer_uploads_spec.rbindex 4eff93c9dc3..34c9fb2bd38 100644--- a/spec/system/composer_uploads_spec.rb+++ b/spec/system/composer_uploads_spec.rb@@ -155,40 +155,27 @@ describe "Uploading files in the composer", type: :system docontext "when multiple images are uploaded" dobefore { SiteSetting.experimental_auto_grid_images = true }- context "when the locale is fr" do- before { SiteSetting.default_locale = "fr" }-- it "works with the French locale" do- visit "/new-topic"- expect(composer).to be_opened-- file_path_1 = file_from_fixtures("logo.png", "images").path- file_path_2 = file_from_fixtures("logo.jpg", "images").path- file_path_3 = file_from_fixtures("downsized.png", "images").path- attach_file("file-uploader", [file_path_1, file_path_2, file_path_3], make_visible: true)-- expect(composer).to have_no_in_progress_uploads- expect(composer.composer_input.value).to match(- %r{\[grid\].*!\[.*?\]\(upload://.*?\).*!\[.*?\]\(upload://.*?\).*!\[.*?\]\(upload://.*?\).*?\[/grid\]}m,- )+ %w[en fr de].each do |locale|+ before { SiteSetting.default_locale = locale }++ context "when the locale is #{locale}" do+ it "automatically wraps images in [grid] tags on 3 or more images" do+ visit "/new-topic"+ expect(composer).to be_opened++ file_path_1 = file_from_fixtures("logo.png", "images").path+ file_path_2 = file_from_fixtures("logo.jpg", "images").path+ file_path_3 = file_from_fixtures("downsized.png", "images").path+ attach_file("file-uploader", [file_path_1, file_path_2, file_path_3], make_visible: true)++ expect(composer).to have_no_in_progress_uploads+ expect(composer.composer_input.value).to match(+ %r{\[grid\].*!\[.*?\]\(upload://.*?\).*!\[.*?\]\(upload://.*?\).*!\[.*?\]\(upload://.*?\).*?\[/grid\]}m,+ )+ endendend- it "automatically wraps images in [grid] tags on 3 or more images" do- visit "/new-topic"- expect(composer).to be_opened-- file_path_1 = file_from_fixtures("logo.png", "images").path- file_path_2 = file_from_fixtures("logo.jpg", "images").path- file_path_3 = file_from_fixtures("downsized.png", "images").path- attach_file("file-uploader", [file_path_1, file_path_2, file_path_3], make_visible: true)-- expect(composer).to have_no_in_progress_uploads- expect(composer.composer_input.value).to match(- %r{\[grid\].*!\[.*?\]\(upload://.*?\).*!\[.*?\]\(upload://.*?\).*!\[.*?\]\(upload://.*?\).*?\[/grid\]}m,- )- end-it "does not wrap [grid] tags on less than 3 images" dovisit "/new-topic"expect(composer).to be_opened