FIX: Strip remote url before import. (#6762)

FIX: Strip remote url before import. (#6762)
diff --git a/app/models/remote_theme.rb b/app/models/remote_theme.rb
index eff45a6..5dbb3a9 100644
--- a/app/models/remote_theme.rb
+++ b/app/models/remote_theme.rb
@@ -39,7 +39,7 @@ class RemoteTheme < ActiveRecord::Base
   end
 
   def self.import_theme(url, user = Discourse.system_user, private_key: nil, branch: nil)
-    importer = ThemeStore::GitImporter.new(url, private_key: private_key, branch: branch)
+    importer = ThemeStore::GitImporter.new(url.strip, private_key: private_key, branch: branch)
     importer.import!
 
     theme_info = JSON.parse(importer["about.json"])
diff --git a/spec/requests/admin/themes_controller_spec.rb b/spec/requests/admin/themes_controller_spec.rb
index 2d9d34d..6788b98 100644
--- a/spec/requests/admin/themes_controller_spec.rb
+++ b/spec/requests/admin/themes_controller_spec.rb
@@ -76,6 +76,14 @@ describe Admin::ThemesController do
       expect(theme.theme_fields.first.upload.original_filename).to eq(upload.original_filename)
     end
 
+    it 'can import a theme from Git' do
+      post "/admin/themes/import.json", params: {
+        remote: '    https://github.com/discourse/discourse-brand-header       '
+      }
+
+      expect(response.status).to eq(201)
+    end
+
     it 'imports a theme' do
       post "/admin/themes/import.json", params: { theme: theme_file }
       expect(response.status).to eq(201)

GitHub
sha: 1023003e

1 Like