fossasia/loklak_webclient

View on GitHub
iframely/plugins/meta/author.js

Summary

Maintainability
A
45 mins
Test Coverage
module.exports = {

    getMeta: function(meta) {

        function getAuthor(value) {
            if (typeof value === "string") {
                if (/^https?:\/\//i.test(value)) {
                    return {
                        author_url: value
                    };
                } else {
                    return {
                        author: value
                    };
                }

            }
        }

        var result = getAuthor(meta.author);

        if (!result && meta.article) {
            result = getAuthor(meta.article.author);
        }

        return result;
    }
};