Validating url c invalidating session in javascript

I thought about doing checks on the string, if it starts with or www, send the string to the Uri Builder class, but this does not help with "" which also must be an Uri.

How can I validate stuff like "" as an Uri, but not "google"?

Assume that this regex will be used for a public URL shortener written in PHP, so URLs like shouldn’t pass (even though they’re technically valid).

Also, in this case I only want to allow the HTTP, HTTPS and FTP protocols. :ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|coop|com|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn--0zwm56d|xn--11b5bs3a9aj6g|xn--80akhbyknj4f|xn--9t4b11yi5a|xn--deba0ad|xn--g6w251d|xn--hgbk6aj7f53bba|xn--hlcj6aya9esc7a|xn--jxalpdlp|xn--kgbechtv|xn--zckzah|ye|yt|yu|za|zm|zw)|(?

Checking the end of the string for .com, , doesn't seem flexible. However this code builds an Uri from a single word - if I pass "google" i get in return "google/" which is not what I need. The problem with this code is that when the string is normal like "google", it throws a Socket Exception.

Also I would like to avoid building the code logic on try/catch constructs. By the way you can replace strings "://" and "http" with their object correspondents Uri. So I have made a variation of your code that handles it: Absolute URIs are characterized by a complete reference to the resource (example: while a relative Uri depends on a previously defined base URI (example: /index.html). This method works in accordance with RFC 2396 and RFC 2732. Abbreviated URLs, this situtation is explained in detail as follows: The URL syntax was designed for unambiguous reference to network resources and extensibility via the URL scheme.

I wanted to share a quick tip on how to validate if a given URI is well formed.

If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.

I am reluctant of using Regular Exp on this because they can have flaws, what if in the future someone invents a popular extension like ".zedo" for example, my reg Exp will not catch it since it will only handle known terminations (.net, etc)[email protected]: Regular expressions may get you in trouble in the future as you mentioned.

So, sticking with standard methods provided by the framework is better.

Is Well Formed Uri String and I think I understand why it validates "google" as a valid Uri.

So, what I need I guess, is a way to check if the end of the string has a .com, .net, .attached to it.

Leave a Reply