as3corelib
as3corelib copied to clipboard
URI.isDirectory is broken
This line (638) in URI's isDirectory method:
return (_path.charAt(path.length - 1) == '/');
should be
return (_path.charAt(_path.length - 1) == '/');
Since field _path
is escaped but property path
is not, for every URI that has escaped characters, charAt will pick a character somewhere in the middle of the string (not at the end) and then see if that character is a slash--which it might be. When that happens, isDirectory returns the wrong result, breaking in turn getFilename, getExtension and isOfFileType methods.
This code:
var u:URI = new URI(); u.unknownToURI("C:\\a b c d\\ab.swf"); trace(u.toString() + " isDir=" + u.isDirectory());
yields
http://c/a%20b%20c%20d/ab.swf isDir=true
I don't have permissions to commit the fix.