示例#1
0
std::string URL::fragment() const
{
    if (hasFragment())
        return _buf.substr(_parser.field_data[UF_FRAGMENT].off,
                           _parser.field_data[UF_FRAGMENT].len);
    return std::string();
}
示例#2
0
文件: url.cpp 项目: delort/libsourcey
void URL::updateFragment(const std::string& fragment)
{
    if (!hasFragment())
        throw std::runtime_error("Cannot update invalid URL");        

    std::string tmp(str());
    util::replaceInPlace(tmp, this->fragment(), fragment);
    parse(tmp);
}
示例#3
0
文件: url.cpp 项目: delort/libsourcey
std::string URL::pathEtc() const
{
    std::string res;    
    res.append(path());    
    if (hasQuery()) {
        res.append("?");
        res.append(query());
    }
    if (hasFragment()) {
        res.append("#");
        res.append(fragment());
    }
    return res;
}
示例#4
0
ParsedURL ParsedURL::withoutFragment() const
{
    if (!hasFragment())
        return *this;

    ParsedURL newURL;

    int charactersBeforeFragemnt = m_segments.charactersBefore(URLSegments::Fragment, URLSegments::DelimiterExcluded);
    newURL.m_spec = URLString(m_spec.string().substringSharingImpl(0, charactersBeforeFragemnt));

    newURL.m_segments = m_segments;
    newURL.m_segments.fragment = URLComponent();
    return newURL;
}