File tree Expand file tree Collapse file tree 3 files changed +17
-7
lines changed
Expand file tree Collapse file tree 3 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -253,11 +253,6 @@ def project_directory_pathname
253253 end
254254 end
255255
256- # Ensure that the project directory is a valid path
257- def safe_directory ( directory )
258- Project . safe_directory ( directory )
259- end
260-
261256 def log_elapsed ( start_time , prefix , message )
262257 elapsed_time = Time . zone . now - start_time
263258 timing_info = "#{ format ( '%.2f' , elapsed_time ) } s"
Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ def self.default_provisionality
4848 def self . safe_directory ( directory )
4949 return "" if directory . nil?
5050
51- # only alphanumeric characters and /
52- directory . strip . gsub ( /[^A-Za-z\d \/ ]/ , "-" )
51+ # only alphanumeric characters, underscores, and /
52+ directory . strip . gsub ( /[^A-Za-z\d _ \/ ]/ , "-" )
5353 end
5454
5555 attr_accessor (
Original file line number Diff line number Diff line change 117117 expect ( project_metadata . title ) . to eq ( "title abc again" )
118118 end
119119 end
120+
121+ describe "#safe_directory" do
122+ it "handles nil values" do
123+ expect ( described_class . safe_directory ( nil ) ) . to eq ""
124+ end
125+
126+ it "honors dashes and underscores" do
127+ expect ( described_class . safe_directory ( "abc_123" ) ) . to eq "abc_123"
128+ expect ( described_class . safe_directory ( "abc-456" ) ) . to eq "abc-456"
129+ end
130+
131+ it "replaces unexpected characters with dashes" do
132+ expect ( described_class . safe_directory ( "hello#world{x}" ) ) . to eq "hello-world-x-"
133+ end
134+ end
120135end
You can’t perform that action at this time.
0 commit comments