+<% file_regex = nil %>
+<% if params[:file_regex] %>
+ <% begin %>
+ <% file_regex = Regexp.new(params[:file_regex]) %>
+ <% rescue RegexpError %>
+ <% # If the pattern is not a valid regex, quote it %>
+ <% # (i.e. use it as a simple substring search) %>
+ <div class="alert alert-info">
+ <p>The search term <code><%= params[:file_regex] %></code> could not be parsed as a regular expression.</p>
+ <p>Searching for files named <code><%= params[:file_regex] %></code> instead.</p>
+ </div>
+ <% file_regex = Regexp.new(Regexp.quote(params[:file_regex])) %>
+ <% end %>
+<% end %>
+