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

Generasi Muda Wajib Tahu! Museum Tsunami Aceh Jadi Pusat Belajar Mitigasi

MUSEUM Tsunami Aceh kembali jadi sorotan. Kali ini, Wakil Menteri Kependudukan dan Pembangunan Keluarga ( Wamen Dukbangga ) atau Wakil Kepala BKKBN , Ratu Ayu Isyana Bagoes Oka , berkunjung langsung untuk melihat bagaimana museum kebanggaan masyarakat Aceh ini terus hidup sebagai pusat edukasi kebencanaan, Kamis, 9 Oktober 2025.  Didampingi Ketua TP PKK Aceh Marlina Usman, kunjungan ini bukan sekadar seremoni. Isyana menegaskan bahwa museum ini punya peran strategis: bukan hanya monumen peringatan tsunami 2004 , tapi juga ruang belajar generasi muda tentang kesiapsiagaan bencana dan ketangguhan keluarga. “Museum ini jadi pengingat dahsyatnya tsunami 2004, sekaligus tempat belajar bagi generasi yang saat itu belum lahir. Mereka perlu tahu apa yang harus dilakukan saat bencana datang,” ujar Isyana, yang juga mengenang pengalamannya meliput langsung Aceh pascatsunami 20 tahun lalu. Kepala UPTD Museum Tsunami Aceh M Syahputra AZ, menyambut hangat kunjungan ini. Ia menegaskan bahw...

Penelitian: Sejarah Aceh Sebelum Masa Kesultanan

Oleh E. Edwards McKinnon* Pengantar Pertama-pertama perlu saya jelaskan bagaimana saya dapat memberikan makalah tentang sejarah Aceh ini. Pada tahun 1975, pada waktu saya masih kerja di Medan dan sebelum saya berangkat ke Cornell untuk belajar untuk S2 dan S3, berdasarkan minat saya belajar tentang sejarah Aceh, Alm H. Mohd Said, pemilik Harian Waspada dan penulis buku  Atjeh Sepanjang Abad  men a warkan sebuah kunjungan bersama ke Aceh.  Kami telah mengunjungi beberapa situs2 purbakala sekitar Lhokseumawe maupun Aceh Besar, termasuk desa Lambaro Neujid, atau situs Indrapurwa di Kec. Lambadeuk maupun benteng Indrapatra di desa Ladong dan Benteng Iskandar Muda diseberang dari desa Meunasahkeude di Kec. Mesjid Besar di wilayah Krueng Raya. Pada waktu itu kami tidak sempat melanjutkan perjalanan ke desa Lamreh atau melihat bekas Benteng Inong Bale atau Kuta Lubhok di Ujung Batee Kapal. Pembatalan mengunjungi desa Lamreh pada waktu itu berakibat pada kekeliruan ...

GenBI UIA, Gelar CBP Rupiah Goes to MAN 2 Bireuen

KANTOR Perwakilan (KPw) Bank Indonesia (BI) Lhokseumawe bekerja sama dengan Generasi Baru Indonesia (GenBI) Komisariat Universitas Islam Aceh (UIA) menggelar kegiatan CBP Rupiah Goes to School di MAN 2 Bireuen pada Sabtu, 20 September 2025 yang berlangsung mulai pukul 09.00 hingga 12.00 WIB di Aula MAN 2 Bireuen. Acara ini dihadiri oleh 100 siswa-siswi kelas XII beserta para guru MAN 2 Bireuen dan menghadirkan pemateri muda inspiratif dari GenBI UIA, yaitu Mahabbi sebagai Ketua Divisi Pendidikan dan Ade Warni sebagai Staf Divisi Publikasi.  Dengan mengusung edukasi Cinta, Bangga, Paham (CBP) Rupiah, dengan tujuan menanamkan rasa cinta terhadap mata uang rupiah, meningkatkan pemahaman mengenai ciri-ciri keaslian rupiah, serta mengajak generasi muda untuk lebih bangga menggunakan rupiah sebagai simbol kedaulatan bangsa. Dalam pemaparannya, Mahabbi menyampaikan pentingnya menjaga rupiah sebagai identitas negara. "Cinta rupiah itu berarti merawat dan menggunakannya dengan baik, tida...