From 3ffdca2efd3e69bf091602df674cbf4bed577f0a Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Wed, 6 Dec 2023 15:41:48 +0000 Subject: [PATCH] Fix auditing filename bug - in the gem components used by applications section of the component auditing, some of the links appeared incomplete or duplicate - this is because those files started with or contained a number, and the regex that converted the full file path into a relative link and github link wasn't including numbers, so the output was incorrect - amending regex to include numbers seems to have solved the problem --- app/models/govuk_publishing_components/audit_applications.rb | 2 +- spec/component_guide/audit_applications_spec.rb | 2 +- spec/dummy/lib/{test_file_1.rb => 1_test_file_1.rb} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename spec/dummy/lib/{test_file_1.rb => 1_test_file_1.rb} (100%) diff --git a/app/models/govuk_publishing_components/audit_applications.rb b/app/models/govuk_publishing_components/audit_applications.rb index d7603aeafc..d73b5fb4f9 100644 --- a/app/models/govuk_publishing_components/audit_applications.rb +++ b/app/models/govuk_publishing_components/audit_applications.rb @@ -161,7 +161,7 @@ def find_code_references(file, src, regex) end def clean_file_path(file) - file[/(?<=#{Regexp.escape(@path.to_s)}\/)[\/a-zA-Z_-]+.[a-zA-Z+.]+/] + file[/(?<=#{Regexp.escape(@path.to_s)}\/)[\/0-9a-zA-Z_-]+.[0-9a-zA-Z+.]+/] end def clean_file_name(name) diff --git a/spec/component_guide/audit_applications_spec.rb b/spec/component_guide/audit_applications_spec.rb index d0e40abf38..84cbd66f6f 100644 --- a/spec/component_guide/audit_applications_spec.rb +++ b/spec/component_guide/audit_applications_spec.rb @@ -45,7 +45,7 @@ "error summary": ["app/views/welcome/error_summary.html.erb"], details: ["app/views/welcome/asset_helper.html.erb"], feedback: ["app/views/layouts/application.html.erb"], - govspeak: ["app/views/welcome/contextual_navigation.html.erb", "lib/test_file_1.rb"], + govspeak: ["app/views/welcome/contextual_navigation.html.erb", "lib/1_test_file_1.rb"], input: ["app/views/welcome/error_summary.html.erb", "app/views/welcome/error_summary.html.erb"], "layout footer": ["app/views/layouts/dummy_admin_layout.html.erb"], "layout for admin": ["app/views/layouts/dummy_admin_layout.html.erb"], diff --git a/spec/dummy/lib/test_file_1.rb b/spec/dummy/lib/1_test_file_1.rb similarity index 100% rename from spec/dummy/lib/test_file_1.rb rename to spec/dummy/lib/1_test_file_1.rb