When article name is a UTF-8 string or contains some UTF-8 characters,
gajus.contents.id(articleName)
will return a empty string, which leads to the Error('Invalid ID.')
My temporary solution:
Implement the function contents.formatId like below
contents.formatId = function (str) {
if (!str.match(/^[a-z]+[a-z0-9\-_:\.]*$/)) {
return "hash" + str.hashCode();
}
};
Then gajus/contents works perfectly.
PS:
The implementation of str.hashCode()
String.prototype.hashCode = function () {
var hash = 0, i, chr, len;
if (this.length == 0) return hash;
for (i = 0, len = this.length; i < len; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
};