modules/utils.js
/**
 *   Format the url for the request
 **/
Format the url for the request
Format the url for the request
function buildSecplugsAPIRequestUrl(url, local_state, capability) {
    console.assert(
        typeof url == 'string' &&
        url.startsWith('http'),
        'url with scheme expected');
    const capabilities = ['/web/score', '/web/quickscan', '/web/deepscan'];
    console.assert(capabilities.includes(capability));
    const scan_context = {
        'client_uuid': local_state['secplugs_client_uuid'],
        'plugin_version': local_state['secplugs_plugin_version']
    };
    const encoded_scancontext = encodeURIComponent(JSON.stringify(scan_context));
    const endpoint = local_state['secplugs_security_api'] + capability;
    const encoded_url = encodeURIComponent(url);
    let request_url = `${endpoint}?url=${encoded_url}&scancontext=${encoded_scancontext}`;
    return request_url;
}
function buildSecplugsAPIRequestUrl ( url , local_state , capability ) { console . assert ( typeof url == 'string' && url . startsWith ( 'http' ) , 'url with scheme expected' ) ; const capabilities = [ '/web/score' , '/web/quickscan' , '/web/deepscan' ] ; console . assert ( capabilities . includes ( capability ) ) ; const scan_context = { 'client_uuid' : local_state [ 'secplugs_client_uuid' ] , 'plugin_version' : local_state [ 'secplugs_plugin_version' ] } ; const encoded_scancontext = encodeURIComponent ( JSON . stringify ( scan_context ) ) ; const endpoint = local_state [ 'secplugs_security_api' ] + capability ; const encoded_url = encodeURIComponent ( url ) ; let request_url = ` ${ endpoint } ${ encoded_url } ${ encoded_scancontext } ` ; return request_url ; }
Format the url for the request
Format the url for the request
// Check valid url // Check valid capability // Scan context // Build and return the url