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

AO3-6625 Replace whitespace in download filenames with underscores #4645

Merged
merged 3 commits into from
Oct 29, 2023

Conversation

sarken
Copy link
Collaborator

@sarken sarken commented Oct 23, 2023

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

@@ -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
Copy link
Contributor

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?

name = extender
elsif name.length < 3
name += "_#{extender}"
end
Copy link
Contributor

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.

@brianjaustin brianjaustin added this to the 0.9.352: Downloads milestone Oct 25, 2023
Copy link
Contributor

@neuroalien neuroalien left a 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!

@neuroalien neuroalien merged commit 86b4fed into otwcode:master Oct 29, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants