[uri] Support URIs containing only scheme and path components

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2016-03-13 14:51:15 +00:00
parent 11ccfb67fa
commit 17c1488a44
2 changed files with 33 additions and 3 deletions

View File

@@ -456,7 +456,6 @@ unsigned int uri_port ( const struct uri *uri, unsigned int default_port ) {
*/
size_t format_uri ( const struct uri *uri, char *buf, size_t len ) {
static const char prefixes[URI_FIELDS] = {
[URI_OPAQUE] = ':',
[URI_PASSWORD] = ':',
[URI_PORT] = ':',
[URI_QUERY] = '?',
@@ -495,9 +494,9 @@ size_t format_uri ( const struct uri *uri, char *buf, size_t len ) {
( buf + used ), ( len - used ) );
/* Suffix this field, if applicable */
if ( ( field == URI_SCHEME ) && ( ! uri->opaque ) ) {
if ( field == URI_SCHEME ) {
used += ssnprintf ( ( buf + used ), ( len - used ),
"://" );
":%s", ( uri->host ? "//" : "" ) );
}
}