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

Guarding against zero length string #151

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

jpodivin
Copy link
Collaborator

@jpodivin jpodivin commented Aug 8, 2024

No description provided.

@TomasTomecek
Copy link
Collaborator

Unfortunely this haven't fixed the issue for me. Locally in chrome (tried private browsing) it still behaves the same :/

I naively tried chrome's dev tools but couldn't see the content of the current-hash-atom and current-hash variables? functions?

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Copy link
Collaborator

@TomasTomecek TomasTomecek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one works really well! Thank you for fixing this.

Let's link this PR with #149

@FrostyX
Copy link
Member

FrostyX commented Aug 9, 2024

Thank you very much for the fix @jpodivin.
For the record, the bug is in:

(def current-hash-atom (r/atom (or (current-hash) "#copr")))

because empty string isn't considered a false value and therefore (or "" "foo") doesn't return "foo" but the empty string. I didn't know that. So the "#copr" default is never used. The proposed fix works, so +1 for that, but it can be simpler:

--- a/frontend/src/app/homepage.cljs
+++ b/frontend/src/app/homepage.cljs
@@ -18,7 +18,9 @@
 (def input-values (r/atom nil))
 (def input-errors (r/atom []))
 (def backend-stats (r/atom nil))
-(def current-hash-atom (r/atom (or (current-hash) "#copr")))
+(def current-hash-atom
+  (r/atom (if (empty? (current-hash)) "#copr" (current-hash))))
+
 (def report-target (r/atom 1000))
 (def error (r/atom nil))

@TomasTomecek TomasTomecek merged commit 59fcc9f into fedora-copr:main Aug 12, 2024
6 checks passed
@jpodivin jpodivin deleted the fix-empty branch August 12, 2024 14:11
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

Successfully merging this pull request may close these issues.

3 participants