The handle_index function now properly constructs HTML anchor tags by splitting the message at the "here: " prefix instead of using the raw upload URL, fixing broken link rendering when the upload URL appears in the success message. The handle_upload function also adds a trailing space after the "here:" prefix to ensure consistent parsing.
The previous implementation used a hardcoded offset of `len("here: ")` from the start of the string after `"here:"`, which would fail if the URL appeared at a different position or if the message structure changed. This commit replaces the brittle slice with a dynamic `str.find()` call to locate the `"here: "` substring, ensuring the URL is correctly extracted regardless of its position in the message. The fix applies to the `handle_index` handler in `src/rupload/app.py`.
The previous implementation incorrectly sliced the URL from the message by starting at the found index without accounting for the length of the upload URL, causing malformed anchor tags when the URL contained trailing slashes. This fix adjusts the slicing to start after the full upload URL string and properly escapes double quotes in the href attribute.
The generate_upload_url method previously concatenated self.upload_url directly with the filename, producing malformed URLs when upload_url did not end with a trailing slash. Changed the concatenation to insert "/" between the base URL and filename, ensuring correct redirect paths regardless of upload_url format.