Commit 4a61ba8f authored by Robert May's avatar Robert May

Improved post receive banner path matching

Resolves an issue raised in
https://gitlab.com/gitlab-org/gitlab/-/issues/216344
parent cb9173ef
......@@ -81,8 +81,12 @@ class PostReceiveService
banner = nil
if project
scoped_messages = BroadcastMessage.current_banner_messages(project.full_path).select do |message|
message.target_path.present? && message.matches_current_path(project.full_path)
# This provides the path in a similar manner to the frontend passing
# the request path, improving regex matching.
path = "/#{project.full_path}"
scoped_messages = BroadcastMessage.current_banner_messages(path).select do |message|
message.target_path.present? && message.matches_current_path(path)
end
banner = scoped_messages.last
......
......@@ -264,7 +264,7 @@ RSpec.describe PostReceiveService do
context "project path matches" do
before do
allow(project).to receive(:full_path).and_return("/company/sekrit-project")
allow(project).to receive(:full_path).and_return("company/sekrit-project")
end
it "does output the latest scoped broadcast message" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment