Function updateQueryParam

  • Update the query param's value of the input URL.

    Usage:

    const ret1 = updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3', 'three');
    const ret2 = updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4', 'four');
    console.log(ret1);
    console.log(ret2);

    Output:

    http://example.com/?t1=1&t2=2&t3=three&t4=4
    http://example.com/?t1=1&t2=2&t3=3&t4=four
    

    Parameters

    • url: string

      URL string.

    • param: string

      Query param.

    • value: string

      Param's value.

    Returns string

    URL.