Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix File.extname for filenames like "a.yml", and make the method easier to understand #6217

Closed
wants to merge 1 commit into from
Closed

Conversation

asterite
Copy link
Member

Fixes #6215

Alternative to #6216, which probably works, but please try to explain me in words what this means:

if dot_index && dot_index != filename.size - 1 && dot_index > ((filename.rindex(SEPARATOR) || -1) + 1)

The regression was probably introduced because the code became hard to understand, practically unreadable. It's better to have small concise checks with comments, so that anyone can quickly understand what the code does.

@asterite
Copy link
Member Author

Actually, nevermind. It should be done like in Go: https://golang.org/src/path/filepath/path.go?s=6131:6159#L207

@asterite asterite closed this Jun 18, 2018
@asterite
Copy link
Member Author

(But I won't send a PR, so someone should do that. Probably going byte per byte, in reverse, over the slice, should work, but it's a boring thing to work on for me)

@straight-shoota
Copy link
Member

@asterite This is actually already implemented in #5635 as Path#extension. This could be backported as bugfix for File.extname, so it can go into 0.25.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants