Skip to content

Fix constraints for the Static Site Editor route

Vasilii Iakliushin requested to merge fix_constraints_for_sse into master

What does this MR do?

A fix for the previous MR: !29453 (merged)

Problem

Current id constraint does not allow routes with . symbol.

  • gitlab-org/gitlab-shell/-/sse/master/CONTRIBUTING - match
  • gitlab-org/gitlab-shell/-/sse/master/CONTRIBUTING.md - 404 page

Solution

This MR restores the previous value for id constraint.

I've added a simple integration test to make sure that routing works as expected.

Before:

$ be rake routes | grep static_site_editor
                                      namespace_project_show_sse GET                   /*namespace_id/:project_id/-/sse/*id(.:format)                                                                     projects/static_site_editor#show {:project_id=>/(?!((?i-mx:\-|badges|blame|blob|builds|commits|create|create_dir|edit|environments\/folders|files|find_file|gitlab\-lfs\/objects|info\/lfs\/objects|new|preview|raw|refs|tree|update|wikis))\/)(?-mix:(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*)(?-mix:(?<!\.git|\.atom)))/, :namespace_id=>/(?-mix:(?!((?i-mx:\-|\.well\-known|404\.html|422\.html|500\.html|502\.html|503\.html|abuse_reports|admin|api|apple\-touch\-icon\-precomposed\.png|apple\-touch\-icon\.png|assets|autocomplete|dashboard|deploy\.html|explore|favicon\.ico|favicon\.png|files|groups|health_check|help|import|invites|jwt|login|oauth|profile|projects|public|robots\.txt|s|search|sent_notifications|slash\-command\-logo\.png|snippets|unsubscribes|uploads|users|v2))\/)(?-mix:(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])(?-mix:(?<!\.git|\.atom))))(?:\/(?!(?i-mx:\-|badges|blame|blob|builds|commits|create|create_dir|edit|environments\/folders|files|find_file|gitlab\-lfs\/objects|info\/lfs\/objects|new|preview|raw|refs|tree|update|wikis)\/)(?-mix:(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])(?-mix:(?<!\.git|\.atom))))*/}

After:

$ be rake routes | grep static_site_editor
                                      namespace_project_show_sse GET                   /*namespace_id/:project_id/-/sse/*id(.:format)                                                                     projects/static_site_editor#show {:project_id=>/(?!((?i-mx:\-|badges|blame|blob|builds|commits|create|create_dir|edit|environments\/folders|files|find_file|gitlab\-lfs\/objects|info\/lfs\/objects|new|preview|raw|refs|tree|update|wikis))\/)(?-mix:(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*)(?-mix:(?<!\.git|\.atom)))/, :namespace_id=>/(?-mix:(?!((?i-mx:\-|\.well\-known|404\.html|422\.html|500\.html|502\.html|503\.html|abuse_reports|admin|api|apple\-touch\-icon\-precomposed\.png|apple\-touch\-icon\.png|assets|autocomplete|dashboard|deploy\.html|explore|favicon\.ico|favicon\.png|files|groups|health_check|help|import|invites|jwt|login|oauth|profile|projects|public|robots\.txt|s|search|sent_notifications|slash\-command\-logo\.png|snippets|unsubscribes|uploads|users|v2))\/)(?-mix:(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])(?-mix:(?<!\.git|\.atom))))(?:\/(?!(?i-mx:\-|badges|blame|blob|builds|commits|create|create_dir|edit|environments\/folders|files|find_file|gitlab\-lfs\/objects|info\/lfs\/objects|new|preview|raw|refs|tree|update|wikis)\/)(?-mix:(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])(?-mix:(?<!\.git|\.atom))))*/, :id=>/[^\0]+/}

(Scroll to the end of the line to check the id constraint)

Screenshots

I've created locally a project with the name sse and it still works.

Screenshot_2020-04-14_at_15.20.38

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Vasilii Iakliushin

Merge request reports