mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-27 16:59:36 +03:00
Add function to get a nsurl with fragment removed from a nsurl.
svn path=/trunk/netsurf/; revision=12903
This commit is contained in:
parent
e3211bf4fc
commit
970d6dd835
@ -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;
|
||||
}
|
||||
|
||||
|
@ -197,4 +197,19 @@ const char *nsurl_access(const nsurl *url);
|
||||
*/
|
||||
nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined);
|
||||
|
||||
|
||||
/**
|
||||
* Create a NetSurf URL object without a fragment from a NetSurf URL
|
||||
*
|
||||
* \param base NetSurf URL to create new NetSurf URL from
|
||||
* \param no_frag Returns new NetSurf URL without fragment
|
||||
* \return NSERROR_OK on success, appropriate error otherwise
|
||||
*
|
||||
* If return value != NSERROR_OK, nothing will be returned in no_frag.
|
||||
*
|
||||
* It is up to the client to call nsurl_destroy when they are finished with
|
||||
* the created object.
|
||||
*/
|
||||
nserror nsurl_defragment(const nsurl *url, nsurl **no_frag);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user