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

changeExtensionTo does not account for multiple dots in file name #603

Open
pr0me opened this issue Apr 30, 2023 · 0 comments
Open

changeExtensionTo does not account for multiple dots in file name #603

pr0me opened this issue Apr 30, 2023 · 0 comments

Comments

@pr0me
Copy link

pr0me commented Apr 30, 2023

The changeExtensionTo method (part of better.files.File) splits file names on the first occurrence of a dot and hence will incorrectly rename any file with multiple extensions.

I confirmed the bug by running the following example:

val test_file_0 = File("./xx.js.md")
val altered_0 = test_file_0.changeExtensionTo(".js")
logger.error(s"TEST 0: ${test_file_0} -> ${altered_0}")
val test_file_1 = File("./xx.md.md")
val altered_1 = test_file_0.changeExtensionTo(".js")
logger.error(s"TEST 1: ${test_file_1} -> ${altered_1}")

will result in

TEST 0: ./xx.js.md -> ./xx.js
TEST 1: ./xx.md.md -> ./xx.js

meaning that is also not only due to the extension and the replacement being the same.

System information:

  • OS: Linux pop-os 6.0.12-76060006-generic 22.04
  • javac 11.0.17
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

No branches or pull requests

1 participant