Skip to content

Commit e3b8d87

Browse files
author
p01
committed
add a getter for the extension of of a filename in the uri class
1 parent c41df9c commit e3b8d87

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/scripts/uri.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ var URIPrototype = function(uri_prop_name)
3939

4040
}, this);
4141

42+
this.__defineGetter__("extension", function()
43+
{
44+
45+
if (!this._extension && (this._is_parsed || this[uri_prop_name]))
46+
{
47+
var pos = this.filename.lastIndexOf(".");
48+
if (pos > -1)
49+
this._extension = this.filename.slice(pos + 1);
50+
else
51+
this._extension = "";
52+
}
53+
54+
return this._extension;
55+
});
56+
57+
this.__defineSetter__("extension", function() {});
58+
4259
this.__defineGetter__("filename", function()
4360
{
4461

0 commit comments

Comments
 (0)