summaryrefslogtreecommitdiff
path: root/app/helpers/import_helper.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-08-23 15:21:06 -0700
committerStan Hu <stanhu@gmail.com>2018-08-24 10:29:14 -0700
commitf2005125dfe7810de910b61dee8d7a9203a6ca6e (patch)
tree292dbe52167f294d75e7637e60c521c02a0cdb4d /app/helpers/import_helper.rb
parent842377ab3c5b80a3758ad8c36dc3358bd265bc10 (diff)
downloadgitlab-ce-f2005125dfe7810de910b61dee8d7a9203a6ca6e.tar.gz
Use slugs for default project path and sanitize names before import
Users importing from Bitbucket Cloud, Bitbucket Server, or GitHub often complained about getting failed imports due to 422 errors. This change ensures that project names are imported with names that are guaranteed to pass the regular expression validation. Part of #50021
Diffstat (limited to 'app/helpers/import_helper.rb')
-rw-r--r--app/helpers/import_helper.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/helpers/import_helper.rb b/app/helpers/import_helper.rb
index 4664b1728c4..c65f1565425 100644
--- a/app/helpers/import_helper.rb
+++ b/app/helpers/import_helper.rb
@@ -5,6 +5,10 @@ module ImportHelper
false
end
+ def sanitize_project_name(name)
+ name.gsub(/[^\w\-]/, '-')
+ end
+
def import_project_target(owner, name)
namespace = current_user.can_create_group? ? owner : current_user.namespace_path
"#{namespace}/#{name}"