-
Notifications
You must be signed in to change notification settings - Fork 515
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
AO3-6625 Replace whitespace in download filenames with underscores #4645
Conversation
@@ -53,7 +53,7 @@ | |||
expect(Download.new(work).file_name).to eq("123456789-123456789-1234") | |||
|
|||
work.title = "123456789 123456789 123456789" | |||
expect(Download.new(work).file_name).to eq("123456789 123456789") | |||
expect(Download.new(work).file_name).to eq("123456789_123456789") | |||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an additional test for the edge case of a work title having several consecutive spaces like A mystery
?
app/models/download.rb
Outdated
name = extender | ||
elsif name.length < 3 | ||
name += "_#{extender}" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My JS-addled immediately thought of "simplifying" that using join
:
name = [name, "Work_#{work.id}"].compact_blank.join("_") if name.length < 3
But not exactly sure this is indeed better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving on the strength of the two existing approvals!
Issue
https://otwarchive.atlassian.net/browse/AO3-6625
Purpose
Replaces the whitespace in download filenames with underscores to ensure the Calibre-generated table of contents works on EPUBs for Kindle. (Refer to Jira for more info on why this should fix it despite seeming unconnected.)
Testing Instructions
Refer to Jira.
Credit
Sarken, she/her