Skip to content

Commit

Permalink
Merge pull request #3484 from DFE-Digital/CAPT-1953-unwanted-requests…
Browse files Browse the repository at this point in the history
…-404-2

CAPT-1953 silence more rollbar errors froms bots
  • Loading branch information
kenfodder authored Jan 9, 2025
2 parents 93c10a7 + f4af9ff commit 55ce668
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,12 @@ def matches?(request)
match "*path", to: "application#handle_unwanted_requests", via: :all, constraints: lambda { |req|
req.path =~ %r{^/(wordpress|wp)}i
}

# 404 - misc head requests
match "*path", to: "application#handle_unwanted_requests", via: :head, constraints: lambda { |req|
req.path =~ %r{^/(backup|bc|bk|home|main|new|old)}i
}

# 404 - root requests
options "/", to: "application#handle_unwanted_requests"
end
22 changes: 22 additions & 0 deletions spec/routes/routes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,27 @@
end
end
end

context "misc head requests" do
it "returns a 404" do
%w[
backup
bc
bk
home
main
new
old
].each do |path|
expect(head: path).to route_to(controller: "application", action: "handle_unwanted_requests", path: path)
end
end
end

context "root requests" do
it "returns a 404" do
expect(options: "/").to route_to(controller: "application", action: "handle_unwanted_requests")
end
end
end
end

0 comments on commit 55ce668

Please sign in to comment.