diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index a3c9decdc9d..e3b0ef90b37 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -30,6 +30,10 @@ def self.exclude_to_regexp(exclude) exclude = exclude[1..-1] end + exclude = "#{exclude}/" if !exclude.end_with?("/") + exclude = "^#{exclude}" + exclude += ".*" if !start_anchor + # This is not an ideal solution, but it's a start. We can improve and # keep unit tests passing in the future. exclude = exclude.gsub("**", "|||GLOBAL|||") diff --git a/test/unit/plugins/synced_folders/rsync/helper_test.rb b/test/unit/plugins/synced_folders/rsync/helper_test.rb index aea2f198bf3..24c47d05b45 100644 --- a/test/unit/plugins/synced_folders/rsync/helper_test.rb +++ b/test/unit/plugins/synced_folders/rsync/helper_test.rb @@ -33,22 +33,22 @@ it "converts a directory match" do expect(described_class.exclude_to_regexp("foo/")). - to eq(/foo\//) + to eq(/^foo\/.[^\/]*/) end it "converts the start anchor" do expect(described_class.exclude_to_regexp("/foo")). - to eq(/foo/) + to eq(/^foo\//) end it "converts the **" do expect(described_class.exclude_to_regexp("fo**o")). - to eq(/fo.*o/) + to eq(/^fo.*o\/.[^\/]*/) end it "converts the *" do expect(described_class.exclude_to_regexp("fo*o")). - to eq(/fo[^\/]*o/) + to eq(/^fo[^\/]*o\/.[^\/]*/) end end