Accept an iHateMoney project name where the id is expected - #99
Open
Pascal-SAPUI5 wants to merge 1 commit into
Open
Accept an iHateMoney project name where the id is expected#99Pascal-SAPUI5 wants to merge 1 commit into
Pascal-SAPUI5 wants to merge 1 commit into
Conversation
Adding an iHateMoney project by hand asks for something the web UI never shows. iHateMoney addresses projects by an id it derives from the name, so a project called "Spongebob house" lives at "spongebob-house" — but the name is the only string a user ever sees. Entering it produced a project that was added, stayed blank, and gave no hint why. The add-project form now converts what was typed the same way the server does: NFKD-normalise, drop everything that is not a word character, whitespace or a hyphen, lowercase, then collapse runs of hyphens and whitespace into one. That mirrors `slugify()` in ihatemoney/utils.py, and it is idempotent — anyone who does enter the real id is unaffected. Cospend is addressed by a case-sensitive share token and is deliberately left alone; normalising that would break every Cospend project. The conversion also explains the second half of InteractionEngineer#53: "something + somethingelse" becomes "something-somethingelse", not "something-+-somethingelse", because the punctuation is dropped before the gap collapses. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #53.
Adding an iHateMoney project by hand asks for something its web UI never shows.
iHateMoney addresses projects by an id derived from the name, so a project
called "Spongebob house" lives at
spongebob-house— but the name is the onlystring a user ever sees. Entering it produced a project that was added, stayed
blank, and gave no hint why. Four people reported this on #53 between 2022 and
2023.
This picks up the offer made there:
What it does
The add-project form now converts what was typed the same way the server does,
mirroring
slugify()inihatemoney/utils.py:this is what removes the accents, and any punctuation
That also explains the second half of the thread:
something + somethingelsebecomes
something-somethingelse, notsomething-+-somethingelse, because the+is dropped in step 2 before the gap collapses in step 4.The conversion is idempotent, so anyone who does enter the real id is
unaffected.
Cospend is addressed by a case-sensitive share token and is deliberately left
untouched — normalising that would break every Cospend project. The choice sits
in
ProjectBackend.projectIdentifier(fromUserInput:)so it is explicit andtestable rather than buried in the Combine chain.
Changes
PayForMe/Util/Util.swift—String.iHateMoneyProjectIdPayForMe/Model/Project.swift—ProjectBackend.projectIdentifier(fromUserInput:)PayForMe/Views/Projects/Manual/AddProjectManualViewModel.swift— use it whenbuilding the project from the form
PayForMeTests/ProjectIdentifierTests.swift— newVerifying
Ten tests, including both cases named in the issue:
testASpaceBecomesAHyphen— "Spongebob house" →spongebob-housetestPunctuationIsDroppedAndTheGapCollapses— "something + somethingelse" →something-somethingelsetestAnIdThatIsAlreadyCorrectIsUnchanged— idempotencetestCospendInputIsUntouched— a mixed-case Cospend token survives verbatima string with nothing usable in it
By hand: add an iHateMoney project by typing the project's name rather than its
id. It now loads.
Not covered
The thread also mentions "Could not find server" being shown when the project,
not the server, is what could not be found. That is a separate problem in how
the error is reported and is not touched here.