Issue #15267 has been updated by jeremyevans0 (Jeremy Evans).

File file-basename-trailing-dot-15267.patch added

Attached is a patch that fixes this issue.  With the patch:

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

----------------------------------------
Bug #15267: File.basename + File.extname does not restore the original name
https://bugs.ruby-lang.org/issues/15267#change-80723

* Author: nobu (Nobuyoshi Nakada)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Related to #15224, I found the case `File.basename(name, '.*')+File.extname(name) == File.basename(name)` is not true.

```ruby
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)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>