{"id":15650788,"url":"https://github.com/schwern/uri-find","last_synced_at":"2025-04-23T15:04:49.737Z","repository":{"id":508561,"uuid":"136140","full_name":"schwern/URI-Find","owner":"schwern","description":"Perl module to find URIs in arbitrary text","archived":false,"fork":false,"pushed_at":"2020-07-27T15:00:39.000Z","size":347,"stargazers_count":12,"open_issues_count":14,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-05T02:39:31.409Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://search.cpan.org/dist/URI-Find","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"3rd-Eden/node-hashring","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schwern.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-02-24T09:37:31.000Z","updated_at":"2020-11-28T05:58:25.000Z","dependencies_parsed_at":"2022-07-04T21:01:37.653Z","dependency_job_id":null,"html_url":"https://github.com/schwern/URI-Find","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwern%2FURI-Find","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwern%2FURI-Find/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwern%2FURI-Find/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwern%2FURI-Find/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schwern","download_url":"https://codeload.github.com/schwern/URI-Find/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262492,"owners_count":20749170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T12:35:50.770Z","updated_at":"2025-03-30T00:41:10.480Z","avatar_url":"https://github.com/schwern.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n\n    URI::Find - Find URIs in arbitrary text\n\nSYNOPSIS\n\n      require URI::Find;\n    \n      my $finder = URI::Find-\u003enew(\\\u0026callback);\n    \n      $how_many_found = $finder-\u003efind(\\$text);\n\nDESCRIPTION\n\n    This module does one thing: Finds URIs and URLs in plain text. It finds\n    them quickly and it finds them all (or what URI.pm considers a URI to\n    be.) It only finds URIs which include a scheme (http:// or the like),\n    for something a bit less strict have a look at URI::Find::Schemeless.\n\n    For a command-line interface, urifind is provided.\n\n Public Methods\n\n    new\n\n        my $finder = URI::Find-\u003enew(\\\u0026callback);\n\n      Creates a new URI::Find object.\n\n      \u0026callback is a function which is called on each URI found. It is\n      passed two arguments, the first is a URI object representing the URI\n      found. The second is the original text of the URI found. The return\n      value of the callback will replace the original URI in the text.\n\n    find\n\n        my $how_many_found = $finder-\u003efind(\\$text);\n\n      $text is a string to search and possibly modify with your callback.\n\n      Alternatively, find can be called with a replacement function for the\n      rest of the text:\n\n        use CGI qw(escapeHTML);\n        # ...\n        my $how_many_found = $finder-\u003efind(\\$text, \\\u0026escapeHTML);\n\n      will not only call the callback function for every URL found (and\n      perform the replacement instructions therein), but also run the rest\n      of the text through escapeHTML(). This makes it easier to turn plain\n      text which contains URLs into HTML (see example below).\n\n Protected Methods\n\n    I got a bunch of mail from people asking if I'd add certain features to\n    URI::Find. Most wanted the search to be less restrictive, do more\n    heuristics, etc... Since many of the requests were contradictory, I'm\n    letting people create their own custom subclasses to do what they want.\n\n    The following are methods internal to URI::Find which a subclass can\n    override to change the way URI::Find acts. They are only to be called\n    inside a URI::Find subclass. Users of this module are NOT to use these\n    methods.\n\n    uri_re\n\n        my $uri_re = $self-\u003euri_re;\n\n      Returns the regex for finding absolute, schemed URIs\n      (http://www.foo.com and such). This, combined with\n      schemeless_uri_re() is what finds candidate URIs.\n\n      Usually this method does not have to be overridden.\n\n    schemeless_uri_re\n\n        my $schemeless_re = $self-\u003eschemeless_uri_re;\n\n      Returns the regex for finding schemeless URIs (www.foo.com and such)\n      and other things which might be URIs. By default this will match\n      nothing (though it used to try to find schemeless URIs which started\n      with www and ftp).\n\n      Many people will want to override this method. See\n      URI::Find::Schemeless for a subclass does a reasonable job of finding\n      URIs which might be missing the scheme.\n\n    uric_set\n\n        my $uric_set = $self-\u003euric_set;\n\n      Returns a set matching the 'uric' set defined in RFC 2396 suitable\n      for putting into a character set ([]) in a regex.\n\n      You almost never have to override this.\n\n    cruft_set\n\n        my $cruft_set = $self-\u003ecruft_set;\n\n      Returns a set of characters which are considered garbage. Used by\n      decruft().\n\n    decruft\n\n        my $uri = $self-\u003edecruft($uri);\n\n      Sometimes garbage characters like periods and parenthesis get\n      accidentally matched along with the URI. In order for the URI to be\n      properly identified, it must sometimes be \"decrufted\", the garbage\n      characters stripped.\n\n      This method takes a candidate URI and strips off any cruft it finds.\n\n    recruft\n\n        my $uri = $self-\u003erecruft($uri);\n\n      This method puts back the cruft taken off with decruft(). This is\n      necessary because the cruft is destructively removed from the string\n      before invoking the user's callback, so it has to be put back\n      afterwards.\n\n    schemeless_to_schemed\n\n        my $schemed_uri = $self-\u003eschemeless_to_schemed($schemeless_uri);\n\n      This takes a schemeless URI and returns an absolute, schemed URI. The\n      standard implementation supplies ftp:// for URIs which start with\n      ftp., and http:// otherwise.\n\n    is_schemed\n\n        $obj-\u003eis_schemed($uri);\n\n      Returns whether or not the given URI is schemed or schemeless. True\n      for schemed, false for schemeless.\n\n    badinvo\n\n        __PACKAGE__-\u003ebadinvo($extra_levels, $msg)\n\n      This is used to complain about bogus subroutine/method invocations.\n      The args are optional.\n\n Old Functions\n\n    The old find_uri() function is still around and it works, but its\n    deprecated.\n\nEXAMPLES\n\n    Store a list of all URIs (normalized) in the document.\n\n      my @uris;\n      my $finder = URI::Find-\u003enew(sub {\n          my($uri) = shift;\n          push @uris, $uri;\n      });\n      $finder-\u003efind(\\$text);\n\n    Print the original URI text found and the normalized representation.\n\n      my $finder = URI::Find-\u003enew(sub {\n          my($uri, $orig_uri) = @_;\n          print \"The text '$orig_uri' represents '$uri'\\n\";\n          return $orig_uri;\n      });\n      $finder-\u003efind(\\$text);\n\n    Check each URI in document to see if it exists.\n\n      use LWP::Simple;\n    \n      my $finder = URI::Find-\u003enew(sub {\n          my($uri, $orig_uri) = @_;\n          if( head $uri ) {\n              print \"$orig_uri is okay\\n\";\n          }\n          else {\n              print \"$orig_uri cannot be found\\n\";\n          }\n          return $orig_uri;\n      });\n      $finder-\u003efind(\\$text);\n\n    Turn plain text into HTML, with each URI found wrapped in an HTML\n    anchor.\n\n      use CGI qw(escapeHTML);\n      use URI::Find;\n    \n      my $finder = URI::Find-\u003enew(sub {\n          my($uri, $orig_uri) = @_;\n          return qq|\u003ca href=\"$uri\"\u003e$orig_uri\u003c/a\u003e|;\n      });\n      $finder-\u003efind(\\$text, \\\u0026escapeHTML);\n      print \"\u003cpre\u003e$text\u003c/pre\u003e\";\n\nNOTES\n\n    Will not find URLs with Internationalized Domain Names or pretty much\n    any non-ascii stuff in them. See\n    http://rt.cpan.org/Ticket/Display.html?id=44226\n\nAUTHOR\n\n    Michael G Schwern \u003cschwern@pobox.com\u003e with insight from Uri Gutman,\n    Greg Bacon, Jeff Pinyan, Roderick Schertler and others.\n\n    Roderick Schertler \u003croderick@argon.org\u003e maintained versions 0.11 to\n    0.16.\n\n    Darren Chamberlain wrote urifind.\n\nLICENSE\n\n    Copyright 2000, 2009-2010, 2014, 2016 by Michael G Schwern\n    \u003cschwern@pobox.com\u003e.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the same terms as Perl itself.\n\n    See http://www.perlfoundation.org/artistic_license_1_0\n\nSEE ALSO\n\n    urifind, URI::Find::Schemeless, URI, RFC 3986 Appendix C\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschwern%2Furi-find","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschwern%2Furi-find","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschwern%2Furi-find/lists"}