diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2011-09-28 11:26:10 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2011-09-28 11:26:10 +0000 |
commit | 970d6dd835d4db60d6264bf3ff1a7553cb683723 (patch) | |
tree | c81611f7d500a6b20d69a9d986a7fb781000f1ed /utils/nsurl.c | |
parent | e3211bf4fc478d78e881386c6df714061417f48d (diff) | |
download | netsurf-970d6dd835d4db60d6264bf3ff1a7553cb683723.tar.gz netsurf-970d6dd835d4db60d6264bf3ff1a7553cb683723.tar.bz2 |
Add function to get a nsurl with fragment removed from a nsurl.
svn path=/trunk/netsurf/; revision=12903
Diffstat (limited to 'utils/nsurl.c')
-rw-r--r-- | utils/nsurl.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/utils/nsurl.c b/utils/nsurl.c index c6fd24425..f3393a91f 100644 --- a/utils/nsurl.c +++ b/utils/nsurl.c @@ -1504,3 +1504,35 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) return NSERROR_OK; } + +/* exported interface, documented in nsurl.h */ +nserror nsurl_defragment(const nsurl *url, nsurl **no_frag) +{ + /* Create NetSurf URL object */ + *no_frag = calloc(1, sizeof(nsurl)); + if (*no_frag == NULL) { + return NSERROR_NOMEM; + } + + /* Get the complete URL string */ + if (nsurl_get(url, NSURL_COMPLETE, &((*no_frag)->string), + &((*no_frag)->length)) != NSERROR_OK) { + free(*no_frag); + return NSERROR_NOMEM; + } + + /* Copy components */ + (*no_frag)->scheme = nsurl__component_copy(url->scheme); + (*no_frag)->username = nsurl__component_copy(url->username); + (*no_frag)->password = nsurl__component_copy(url->password); + (*no_frag)->host = nsurl__component_copy(url->host); + (*no_frag)->port = nsurl__component_copy(url->port); + (*no_frag)->path = nsurl__component_copy(url->path); + (*no_frag)->query = nsurl__component_copy(url->query); + + /* Give the URL a reference */ + (*no_frag)->count = 1; + + return NSERROR_OK; +} + |