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

File.basename returns frozen String #2343

Closed
jeremyevans opened this issue May 3, 2021 · 2 comments
Closed

File.basename returns frozen String #2343

jeremyevans opened this issue May 3, 2021 · 2 comments
Assignees
Milestone

Comments

@jeremyevans
Copy link
Contributor

A few of Roda's tests are failing on TruffleRuby because File.basename is returning a frozen string, while CRuby and JRuby return a new unfrozen string: https://github.com/jeremyevans/roda/runs/2492967121?check_suite_focus=true#step:4:17

Code in question:

            param_filename = File.basename(filename)
            encoding = param_filename.encoding

            needs_encoding = param_filename.gsub!(/[^ 0-9a-zA-Z!\#$&\+\.\^_`\|~]+/, '-') # FrozenError raised here
@eregon
Copy link
Member

eregon commented May 3, 2021

Thank you for the report!
It's probably a case where the argument is returned (no / in the given path), and the argument is a frozen String.

@bjfish Could you fix it?

@eregon eregon added this to the 21.2.0 milestone May 10, 2021
@eregon
Copy link
Member

eregon commented May 10, 2021

Fixed in d2c8638

@eregon eregon closed this as completed May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants