Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by ikegami (Pope)
on Nov 01, 2006 at 18:28 UTC ( #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]) + "]";


Comment on Re^3: Monk Links - Copy Perlmonks-links to the clipboard in on-site-format
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2014-08-01 17:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (36 votes), past polls