PopClip JavaScript API Reference
    Preparing search index...

    Class URLSearchParams

    An ordered list of name–value pairs, representing a parsed URL query string. This is the standard Web API URLSearchParams class: MDN documents it in further depth, though only the members declared here are guaranteed to be present.

    Obtain one from a URL's searchParams property, or construct one standalone. Names and values are stored in decoded form; percent-decoding happens on parsing and encoding on serialization. The same name may appear in more than one pair: append adds a pair unconditionally while set replaces, and get returns the first value while getAll returns all of them.

    Note that toString serializes in application/x-www-form-urlencoded form, which encodes spaces as + rather than %20. See PopClip.openUrl for how PopClip compensates for this.

    const params = new URLSearchParams("a=1&b=2");
    params.append("b", "3");
    print(params.get("a")); // 1
    print(params.getAll("b").join(",")); // 2,3
    print(params.toString()); // a=1&b=2&b=3
    Index
    • Parameters

      • Optionalinit: string | Record<string, string> | URLSearchParams | string[][]

        The initial pairs: a query string (an initial ?, if present, is ignored), an array of [name, value] pairs, an object of names to values, or another URLSearchParams to copy. Omit for an empty list.

      Returns URLSearchParams

    • Same as entries: iterating the object itself yields [name, value] pairs.

      Returns IterableIterator<[string, string]>

    • Adds a pair to the end of the list, keeping any existing pairs with the same name.

      Parameters

      • name: string
      • value: string

      Returns void

    • Removes all pairs with the given name.

      Parameters

      • name: string

      Returns void

    • Iterates over the pairs as [name, value] arrays.

      Returns IterableIterator<[string, string]>

    • Calls a function once for each pair, in order.

      Parameters

      Returns void

    • Returns the value of the first pair with the given name, or null if there is none.

      Parameters

      • name: string

      Returns string | null

    • Returns the values of all pairs with the given name, in order.

      Parameters

      • name: string

      Returns string[]

    • Returns whether at least one pair with the given name exists.

      Parameters

      • name: string

      Returns boolean

    • Iterates over the names, in pair order. A repeated name appears once per pair.

      Returns IterableIterator<string>

    • Sets the value of the first pair with the given name and removes any others — or appends the pair if the name is not present.

      Parameters

      • name: string
      • value: string

      Returns void

    • Sorts the pairs by name, keeping the relative order of pairs with the same name.

      Returns void

    • Serializes the pairs as a query string in application/x-www-form-urlencoded form (spaces become +), without a leading ?.

      Returns string

    • Iterates over the values, in pair order.

      Returns IterableIterator<string>