Project

General

Profile

Bug #15267

File.basename + File.extname does not restore the original name

Added by nobu (Nobuyoshi Nakada) almost 2 years ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:89615]

Description

Related to #15224, I found the case File.basename(name, '.*')+File.extname(name) == File.basename(name) is not true.

name = 'file.'
File.basename(name, '.*') #=> "name"
File.extname(name) #=> ""

Both do not contain the last dot.

basename(1) seems to result in the base name with the dot, when stripping a wildcard suffix.

$ basename name. '.*'
name.

Files

file-basename-trailing-dot-15267.patch (1.96 KB) file-basename-trailing-dot-15267.patch jeremyevans0 (Jeremy Evans), 08/13/2019 11:48 PM

Related issues

Related to Ruby master - Bug #15244: Method #extname return empty string if filename is dot ('.')ClosedActions

Also available in: Atom PDF