All files / utils getUrlParameter.ts

90.91% Statements 10/11
50% Branches 2/4
100% Functions 1/1
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 181x 1x 1x       1x 1x   1x 1x 1x       1x    
export function getUrlParameter(sParam: string): string | true {
    const sPageURL = decodeURIComponent(window.location.search.substring(1));
    const sURLVariables = sPageURL.split("&");
    let sParameterNameValue: string[];
    let sParameterName: string | true;
 
    for (let i = 0; i < sURLVariables.length; i++) {
        sParameterNameValue = sURLVariables[i].split("=");
 
        Eif (sParameterNameValue[0] === sParam) {
            Iif (sParameterNameValue[1] === undefined) sParameterName = true;
            else sParameterName = sParameterNameValue[1];
        }
    }
 
    return sParameterName;
}