Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by holli (Abbot)
on Mar 06, 2005 at 20:59 UTC ( [id://437085]=note: print w/replies, xml ) Need Help??


in reply to Re: 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

Ah, it seems I am not very good at writing documentations.
What would be cool for extentions, holli, is if you did likewise for perldoc, doc, and cpan links.
Actually I have a new version ready that works for cpan://* and kobes://* links, but there is a ugly bug. The entity %3A (double colon) gets not correctly decoded by the decodeURI function. I am trying to figure out why.

As for the perldoc, I will add that when I am sure the currently selected perldoc site will not change.


holli, /regexed monk/
  • Comment on Re^2: Monk Links - Copy Perlmonks-links to the clipboard in on-site-format
  • Download Code

Replies are listed 'Best First'.
Re^3: Monk Links - Copy Perlmonks-links to the clipboard in on-site-format
by The Mad Hatter (Priest) on Mar 06, 2005 at 21:05 UTC
    As a quick hack, you could do decodeURI(s).replace('%3a',':');.
      Thanks a lot The Mad Hatter. But that must be decodeURI(s).replace(/%3a/gi,':');. Otherwise only the first occurance is replaced.


      holli, /regexed monk/
        Urk, you're right. Sorry about that.
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

    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]) + "]";
Re^3: Monk Links - Copy Perlmonks-links to the clipboard in on-site-format
by belg4mit (Prior) on Nov 20, 2005 at 18:24 UTC
    That might be because decodeURI is a complement to encodeURI which encodes non-valid entities. : is avalid entity in a URI

    --
    In Bob We Trust, All Others Bring Data.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-18 22:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found