| 147 | } |
| 148 | |
| 149 | std::string URI::toString() const { |
| 150 | std::string uri; |
| 151 | if ( isRelative() ) { |
| 152 | encode( mPath, RESERVED_PATH, uri ); |
| 153 | } else { |
| 154 | uri = mScheme; |
| 155 | uri += ':'; |
| 156 | std::string auth = getAuthority(); |
| 157 | if ( !auth.empty() || mScheme == "file" ) { |
| 158 | uri.append( "//" ); |
| 159 | uri.append( auth ); |
| 160 | } |
| 161 | if ( !mPath.empty() ) { |
| 162 | if ( !auth.empty() && mPath[0] != '/' ) |
| 163 | uri += '/'; |
| 164 | encode( mPath, RESERVED_PATH, uri ); |
| 165 | } else if ( !mQuery.empty() || !mFragment.empty() ) { |
| 166 | uri += '/'; |
| 167 | } |
| 168 | } |
| 169 | if ( !mQuery.empty() ) { |
| 170 | uri += '?'; |
| 171 | uri.append( mQuery ); |
| 172 | } |
| 173 | if ( !mFragment.empty() ) { |
| 174 | uri += '#'; |
| 175 | encode( mFragment, RESERVED_FRAGMENT, uri ); |
| 176 | } |
| 177 | return uri; |
| 178 | } |
| 179 | |
| 180 | std::string URI::getAuthorityAndPath() const { |
| 181 | std::string uri; |
no test coverage detected