js function to get filename from url

Posted by Blankman on Stack Overflow See other posts from Stack Overflow or by Blankman
Published on 2009-02-04T15:11:45Z Indexed on 2010/03/19 20:11 UTC
Read the original article Hit count: 149

Filed under:
|

Hi,

I have a url like http://www.example.com/blah/th.html

I need a javascript function to give me the 'th' value from that.

All my urls have the same format (2 letter filenames, with .html extension).

I want it to be a safe function, so if someone passes in an empty url it doesn't break.

I know how to check for length, but I should be checking for null to right?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about function