url - path+query component.

This commit is contained in:
Kelvin Sherlock 2012-04-19 20:45:35 -04:00
parent 9aca19b10f
commit afe71ebe02
3 changed files with 8 additions and 7 deletions

View File

@ -4,8 +4,8 @@ OBJS = gopher.o url.o connection.o readline2.o scheme.o ftype.o setftype.o
gopher: $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@
utest: utest.o url.o
$(CC) $(LDFLAGS) utest.o url.o -o $@
utest: utest.o url.o scheme.o
$(CC) $(LDFLAGS) utest.o url.o scheme.o -o $@
dtest: dtest.o dictionary.o
$(CC) $(LDFLAGS) dtest.o dictionary.o -o $@

8
url.c
View File

@ -4,10 +4,9 @@
#include <stdlib.h>
#include <ctype.h>
#include "url.h"
enum {
kScheme,
kUser,
@ -145,7 +144,7 @@ int ParseURL(const char *url, int length, struct URLComponents *components)
components->scheme = range;
parseScheme(url, i, components);
parse_scheme(url, i, components);
++i; // skip the ':'
}
@ -415,7 +414,6 @@ int ParseURL(const char *url, int length, struct URLComponents *components)
components->portNumber = p;
}
#if 0
// path and query.
// path;params?query
range = components->path;
@ -423,12 +421,12 @@ int ParseURL(const char *url, int length, struct URLComponents *components)
{
if (components->params.length)
range.length += components->params.length + 1;
if (components->query.length)
range.length += components->query.length + 1;
components->pathAndQuery = range;
}
#endif
return 1;

View File

@ -46,6 +46,9 @@ void test(const char *url)
URLComponentGetC(url, &data, URLComponentFragment, buffer);
printf(" fragment: %s\n", buffer);
URLComponentGetC(url, &data, URLComponentPathAndQuery, buffer);
printf(" path+query: %s\n", buffer);
free(buffer);