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

Reflection warning on java.net.URLDecoder/decode #207

Open
harold opened this issue Mar 19, 2021 · 0 comments
Open

Reflection warning on java.net.URLDecoder/decode #207

harold opened this issue Mar 19, 2021 · 0 comments

Comments

@harold
Copy link

harold commented Mar 19, 2021

First, thanks for bidi - it's great, we have used it for frontend and backend routing for years and it has greatly simplified swaths of code around urls. If it didn't exist, we'd need to start by making something just like it (but ours would be worse).

Low-priority note:

I get a reflection warning while compiling bidi:

$ lein check
Compiling namespace bidi.bidi
Reflection warning, bidi/bidi.cljc:20:31 - call to static method decode on java.net.URLDecoder can't be resolved (argument types: java.lang.String, unknown).
Compiling namespace bidi.ring
Compiling namespace bidi.schema
Compiling namespace bidi.verbose
Compiling namespace bidi.vhosts

It's right here:

I experimented with this:

diff --git a/src/bidi/bidi.cljc b/src/bidi/bidi.cljc
index 9fca662..645122b 100644
--- a/src/bidi/bidi.cljc
+++ b/src/bidi/bidi.cljc
@@ -16,7 +16,7 @@
 (defn url-decode
   ([string] #?(:clj (url-decode string "UTF-8")
                :cljs (some-> string str (js/decodeURIComponent))))
-  #?(:clj ([string encoding]
+  #?(:clj ([string ^String encoding]
            (some-> string str (java.net.URLDecoder/decode encoding)))))

And it's cleaned up:

$ lein check
Compiling namespace bidi.bidi
Compiling namespace bidi.ring
Compiling namespace bidi.schema
Compiling namespace bidi.verbose
Compiling namespace bidi.vhosts

iiuc, this should be a safe change, because the two-argument arity of static /decode always takes two strings. Maybe this would be a nice improvement to include in a future release.

Thanks again for your time and consideration.

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

No branches or pull requests

1 participant