You're replicating function that already deals with it https://github.com/mozilla/addon-sdk/pull/1003/files#L4R33
please don't.