Langsung ke konten utama

How To Recognize Valid URL from Text

Twitter and host of Twitter clients as well as tons of other programs have to recognize valid URL's (protocol defined in RFC 1738) from plain text and hyperlink them. Unfortunately dues tyo lazyness (or lack of knowledge) of the programmers such URL detection schemes are often hare-brained and fails torecognize valid URL's properly.

URL can use a wide variety of characters and you need to recognize all of them to properly identify and isolate an URL from surrounding text. Here is a simple guide for programmers (based on RFC 1738 obviously):
In general, URLs are written as follows:
:

   A URL contains the name of the scheme being used () followed
   by a colon and then a string (the ) whose
   interpretation depends on the scheme.

   Scheme names consist of a sequence of characters. The lower case
   letters "a"--"z", digits, and the characters plus ("+"), period
   ("."), and hyphen ("-") are allowed. For resiliency, programs
   interpreting URLs should treat upper case letters as equivalent to
   lower case in scheme names (e.g., allow "HTTP" as well as "http").

URLs are written only with the graphic printable characters of the
   US-ASCII coded character set. The octets 80-FF hexadecimal are not
   used in US-ASCII, and the octets 00-1F and 7F hexadecimal represent
   control characters; these must be encoded.

   Unsafe:

   Characters can be unsafe for a number of reasons.  The space
   character is unsafe because significant spaces may disappear and
   insignificant spaces may be introduced when URLs are transcribed or
   typeset or subjected to the treatment of word-processing programs.
   The characters "<" and ">" are unsafe because they are used as the
   delimiters around URLs in free text; the quote mark (""") is used to
   delimit URLs in some systems.  The character "#" is unsafe and should
   always be encoded because it is used in World Wide Web and in other
   systems to delimit a URL from a fragment/anchor identifier that might
   follow it.  The character "%" is unsafe because it is used for
   encodings of other characters.  Other characters are unsafe because
   gateways and other transport agents are known to sometimes modify
   such characters. These characters are "{", "}", "|", "\", "^", "~",
   "[", "]", and "`".

   All unsafe characters must always be encoded within a URL. For
   example, the character "#" must be encoded within URLs even in
   systems that do not normally deal with fragment or anchor
   identifiers, so that if the URL is copied into another system that
   does use them, it will not be necessary to change the URL encoding.

   Reserved:

   Many URL schemes reserve certain characters for a special meaning:
   their appearance in the scheme-specific part of the URL has a
   designated semantics. If the character corresponding to an octet is
   reserved in a scheme, the octet must be encoded.  The characters ";",
   "/", "?", ":", "@", "=" and "&" are the characters which may be
   reserved for special meaning within a scheme. No other characters may
   be reserved within a scheme.

   Usually a URL has the same interpretation when an octet is
   represented by a character and when it encoded. However, this is not
   true for reserved characters: encoding a character reserved for a
   particular scheme may change the semantics of a URL.

   Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
   reserved characters used for their reserved purposes may be used
   unencoded within a URL.

   On the other hand, characters that are not required to be encoded
   (including alphanumerics) may be encoded within the scheme-specific
   part of a URL, as long as they are not being used for a reserved
   purpose.
 
Twitter itself doesn't recognize some of them at the end. Twitter clients like Tweetdeck or Brizzly fails to recognize a ) even in the middle!
Is compliance with standards too much to expect from a 100 million dollar company?

source : http://blog.taragana.com/index.php/archive/how-to-recognize-valid-url-from-text/

POPULAR

Museum Tsunami Aceh Persiapkan Inovasi berbasis Teknologi Digital

MUSEUM Tsunami Aceh terus lakukan inovasi untuk menjadi destinasi edukasi kebencanaan yang lebih modern dan menarik. Dengan mengusung konsep digitalisasi, museum akan memberikan pengalaman baru yang lebih interaktif dan imersif bagi para pengunjung. Kepala Dinas Kebudayaan dan Pariwisata Aceh, Almuniza Kamal, menjelaskan bahwa empat ruang utama di museum akan ditata ulang secara signifikan. Ruang-ruang tersebut meliputi lorong tsunami, memorium hall, lobi lantai dua, dan ruang pameran tetap. "Kami ingin menghadirkan pengalaman yang lebih mendalam dan menyentuh bagi pengunjung. Lorong tsunami akan dilengkapi dengan visual 3D pada lantai dan dinding, menciptakan sensasi seolah berada di tengah gelombang tsunami," ujar Almuniza, Rabu, 17 September 2025. Sementara itu, memorium hall yang ikonik akan diperbaharui dengan serangkaian LED berbentuk persegi panjang, menggantikan layar yang sudah ada. Tujuannya adalah untuk menampilkan konten-konten sejarah dan edukasi secara lebih d...

1,8 Juta Penderita Kanker Mati Akibat Merokok

Kebiasaan merokok adalah salah satu faktor utama penyebab kanker paru. Berdasarkan data Badan Kesehatan Dunia (WHO), 40 persen dari 12 juta orang di dunia didiagnosa terserang kanker setiap tahun. WHO memperkirakan, 84 juta orang meninggal akibat kanker dalam rentang 2005-2015. Ada 1,8 juta angka kematian aki­bat kanker yang disebabkan kebiasaan merokok. Sebesar 60 persen dari keseluruhan angka kematian akibat kebiasaan me­rokok dijumpai di negara-negara berkembang dan terbelakang. Bagaimana rokok dapat me­nimbulkan kanker? Kebiasaan merokok bisa memicu kanker paru, kanker paru, tenggorokan, rongga mulut dan pharynx.

Top Ten Facebook Alternatives That Keep Up Your Privacy

With the rise to top spot in social networking world, Facebook's taking advantage of its monopoly. The social networking ace is eager on controlling online identity of its members and reconfiguring the world’s privacy norms. Lately Facebook has been accused of taking advantage of users privacy. In such a situation you must be looking for Facebook Alternatives. If you are looking for alternatives, you have many but those that upkeep your privacy and offer similar features and apps as Facebook are numbered. We made an effort to queue up the 10 Facebook alternatives that doesn't compromise your privacy. 1. Friendster It is already quite popular in Asia but has also grown in popularity in the United States. The network offers quite a few features to customize your profile, offering quite a few features to customize. This is the ultimate point of a social network through. You can stay updated on people's shared information  Friendster’s privacy is stricter than what we find w...