Next.js Discord

Discord Forum

question about coding

Unanswered
Black-whiskered Vireo posted this in #help-forum
Open in Discord
Black-whiskered VireoOP
I code query parameter 'Alfa Romeo'
I get aaa=Alfa%2520Romeo
       if(a) {
            console.log(a.label);
            let a_val = encodeURIComponent(a.label);
            query_params.set("a", a_val);
        };


is it ok?

5 Replies

American Crow
it's just url encoding / decoding you can double check using online tools .e.g
https://meyerweb.com/eric/tools/dencoder/

However Alfa Romeo is encoded Alfa%20Romeo
Having Alfa%2520Romeo you most likely accidentally encoded twice
Black-whiskered VireoOP
OK Thanks
@Black-whiskered Vireo I code query parameter 'Alfa Romeo' I get aaa=Alfa%2520Romeo if(a) { console.log(a.label); let a_val = encodeURIComponent(a.label); query_params.set("a", a_val); }; is it ok?
this code is wrong, it is encoding the string twice

Alfa Romeo
Alfa%20Romeo (space becomes %20)
Alfa%2520Romeo (% becomes %25)

just query_params.set("a", a.label) should already be good.
Black-whiskered VireoOP
What bundler does Angular use?
v18