http://www.perlmonks.org?node_id=581723


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]) + "]";