diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-09-13 11:38:31 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-09-13 11:38:31 +0900 |
| commit | 5bfb70e9dbc8636730bab7725b3eaf5423a2e30f (patch) | |
| tree | 1d7bf42fe995a2a6c1143782278844cfea03b609 | |
| parent | 8b65e4b73c93f38df8960c698d9bcf34851b6764 (diff) | |
| download | mruby-5bfb70e9dbc8636730bab7725b3eaf5423a2e30f.tar.gz mruby-5bfb70e9dbc8636730bab7725b3eaf5423a2e30f.zip | |
Fix `File.extname` bug; fix #5077
| -rw-r--r-- | mrbgems/mruby-io/mrblib/file.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/mrbgems/mruby-io/mrblib/file.rb b/mrbgems/mruby-io/mrblib/file.rb index 1854deb4e..aa73252e1 100644 --- a/mrbgems/mruby-io/mrblib/file.rb +++ b/mrbgems/mruby-io/mrblib/file.rb @@ -191,9 +191,9 @@ class File < IO def self.extname(filename) fname = self.basename(filename) - return '' if fname[0] == '.' || fname.index('.').nil? - ext = fname.split('.').last - ext.empty? ? '' : ".#{ext}" + epos = fname.rindex('.') + return '' if epos == 0 || epos.nil? + return fname[epos..-1] end def self.path(filename) |
