Beispiel #1
0
String Location::getParameter(const String& name) const
{
    if (!m_frame)
        return String();

    ParsedURLParameters parameters;
    url().copyParsedQueryTo(parameters);
    return parameters.get(name);
}
void KURL::copyParsedQueryTo(ParsedURLParameters& parameters) const
{
    String query = m_url.componentString(m_url.m_parsed.query);
    const UChar* pos = query.characters();
    const UChar* end = query.characters() + query.length();
    while (pos < end) {
        const UChar* parameterStart = pos;
        while (pos < end && *pos != '&')
            ++pos;
        const UChar* parameterEnd = pos;
        if (pos < end) {
            ASSERT(*pos == '&');
            ++pos;
        }
        if (parameterStart == parameterEnd)
            continue;
        const UChar* nameStart = parameterStart;
        const UChar* equalSign = parameterStart;
        while (equalSign < parameterEnd && *equalSign != '=')
            ++equalSign;
        if (equalSign == nameStart)
            continue;
        String name(nameStart, equalSign - nameStart);
        String value = equalSign == parameterEnd ? String() : String(equalSign + 1, parameterEnd - equalSign - 1);
        parameters.set(name, value);
    }
}
String HTMLAnchorElement::getParameter(const String& name) const
{
    ParsedURLParameters parameters;
    href().copyParsedQueryTo(parameters);
    return parameters.get(name);
}