File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
src/main/ruby/truffleruby/core Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 12
12
File . extname ( ".app.conf" ) . should == ".conf"
13
13
end
14
14
15
+ it "returns unfrozen strings" do
16
+ File . extname ( "foo.rb" ) . frozen? . should == false
17
+ File . extname ( "/foo/bar.rb" ) . frozen? . should == false
18
+ File . extname ( "/foo.rb/bar.c" ) . frozen? . should == false
19
+ File . extname ( "bar" ) . frozen? . should == false
20
+ File . extname ( ".bashrc" ) . frozen? . should == false
21
+ File . extname ( "/foo.bar/baz" ) . frozen? . should == false
22
+ File . extname ( ".app.conf" ) . frozen? . should == false
23
+ end
24
+
15
25
it "returns the extension for edge cases" do
16
26
File . extname ( "" ) . should == ""
17
27
File . extname ( "." ) . should == ""
Original file line number Diff line number Diff line change @@ -484,21 +484,21 @@ def self.extname(path)
484
484
dot_idx = Primitive . find_string_reverse ( path , '.' , path_size )
485
485
486
486
# No dots at all
487
- return '' unless dot_idx
487
+ return + '' unless dot_idx
488
488
489
489
slash_idx = Primitive . find_string_reverse ( path , '/' , path_size )
490
490
491
491
# pretend there is / just to the left of the start of the string
492
492
slash_idx ||= -1
493
493
494
494
# no . in the last component of the path
495
- return '' if dot_idx < slash_idx
495
+ return + '' if dot_idx < slash_idx
496
496
497
497
# last component starts with a .
498
- return '' if dot_idx == slash_idx + 1
498
+ return + '' if dot_idx == slash_idx + 1
499
499
500
500
# last component ends with a .
501
- return '' if dot_idx == path_size - 1
501
+ return + '' if dot_idx == path_size - 1
502
502
503
503
path . byteslice ( dot_idx , path_size - dot_idx )
504
504
end
You can’t perform that action at this time.
0 commit comments