Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: Monk Links - Copy Perlmonks-links to the clipboard in on-site-format

by ikegami (Patriarch)
on Nov 01, 2006 at 18:28 UTC ( [id://581723]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Monk Links - Copy Perlmonks-links to the clipboard in on-site-format
in thread Monk Links - Copy Perlmonks-links to the clipboard in on-site-format

decodeURI "does not decode escape sequences that could not have been introduced by encodeURI."

In other words, decodeURI won't return an invalid URI, like decoding %3A does or could do. You can't safely decode an entire URI. Each path segment, each attribute key and each attribute value must be isolated before they can be decoded. For example http%3A//www.google.com/ (a relative URI) and http://www.google.com/ (an absolute URI) are not equivalent.

Not what you want:

decodeURI("http://search.cpan.org/search?mode=module&query=XML%3A%3APa +rser")

What you want:

decodeURIComponent("XML%3A%3AParser")

Since your code already extracts the compenent, simply use

clickedLink = "[cpan://" + decodeURIComponent(array[1]) + "]";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://581723]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2024-04-19 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found