source/node/tools/entry.js
function getEntryURLs(properties, preference = ENTRY_URL_TYPE_ANY) {
    const urlRef = Object.keys(properties)
        .filter(key => URL_PROP.test(key))
        .reduce(
            (output, nextKey) =>
                Object.assign(output, {
                    [nextKey]: properties[nextKey]
                }),
            {}
        );
    if (preference === ENTRY_URL_TYPE_GENERAL || preference === ENTRY_URL_TYPE_LOGIN) {
        return Object.keys(urlRef)
            .sort((a, b) => {
                if (preference === ENTRY_URL_TYPE_GENERAL) {
                    const general = /^ur[li]$/i;
                    const aVal = general.test(a) ? 1 : 0;
                    const bVal = general.test(b) ? 1 : 0;
                    return bVal - aVal;
                } else if (preference === ENTRY_URL_TYPE_LOGIN) {
                    const login = /login/i;
                    const aVal = login.test(a) ? 1 : 0;
                    const bVal = login.test(b) ? 1 : 0;
                    return bVal - aVal;
                }
                return 0;
            })
            .map(key => urlRef[key]);
    } else if (preference === ENTRY_URL_TYPE_ICON) {
        const iconProp = Object.keys(urlRef).find(key => URL_PROP_ICON.test(key));
        return iconProp ? [urlRef[iconProp]] : [];
    }
    // Default is "any" URLs
    return objectValues(urlRef);
}
function getEntryURLs(properties, preference = ENTRY_URL_TYPE_ANY) {
    const urlRef = Object.keys(properties)
        .filter(key => URL_PROP.test(key))
        .reduce(
            (output, nextKey) =>
                Object.assign(output, {
                    [nextKey]: properties[nextKey]
                }),
            {}
        );
    if (preference === ENTRY_URL_TYPE_GENERAL || preference === ENTRY_URL_TYPE_LOGIN) {
        return Object.keys(urlRef)
            .sort((a, b) => {
                if (preference === ENTRY_URL_TYPE_GENERAL) {
                    const general = /^ur[li]$/i;
                    const aVal = general.test(a) ? 1 : 0;
                    const bVal = general.test(b) ? 1 : 0;
                    return bVal - aVal;
                } else if (preference === ENTRY_URL_TYPE_LOGIN) {
                    const login = /login/i;
                    const aVal = login.test(a) ? 1 : 0;
                    const bVal = login.test(b) ? 1 : 0;
                    return bVal - aVal;
                }
                return 0;
            })
            .map(key => urlRef[key]);
    } else if (preference === ENTRY_URL_TYPE_ICON) {
        const iconProp = Object.keys(urlRef).find(key => URL_PROP_ICON.test(key));
        return iconProp ? [urlRef[iconProp]] : [];
    }
    // Default is "any" URLs
    return objectValues(urlRef);
}
function getEntryURLs ( properties , preference = ENTRY_URL_TYPE_ANY ) { const urlRef = Object . keys ( properties ) . filter ( key => URL_PROP . test ( key ) ) . reduce ( ( output , nextKey ) => Object . assign ( output , { [ nextKey ] : properties [ nextKey ] } ) , { } ) ; if ( preference === ENTRY_URL_TYPE_GENERAL || preference === ENTRY_URL_TYPE_LOGIN ) { return Object . keys ( urlRef ) . sort ( ( a , b ) => { if ( preference === ENTRY_URL_TYPE_GENERAL ) { const general = / ^ur[li]$ / i ; const aVal = general . test ( a ) ? 1 : 0 ; const bVal = general . test ( b ) ? 1 : 0 ; return bVal - aVal ; } else if ( preference === ENTRY_URL_TYPE_LOGIN ) { const login = / login / i ; const aVal = login . test ( a ) ? 1 : 0 ; const bVal = login . test ( b ) ? 1 : 0 ; return bVal - aVal ; } return 0 ; } ) . map ( key => urlRef [ key ] ) ; } else if ( preference === ENTRY_URL_TYPE_ICON ) { const iconProp = Object . keys ( urlRef ) . find ( key => URL_PROP_ICON . test ( key ) ) ; return iconProp ? [ urlRef [ iconProp ] ] : [ ] ; } // Default is "any" URLs return objectValues ( urlRef ) ; }
Get URLs from an entry's properties
Allows for preferential sorting
@param {Object} properties The entry properties
@param {*} preference
Get URLs from an entry s properties Allows for preferential sorting