mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 04:02:34 +03:00
make nsurl_defragment() API more obvious and remove duplicated parameter checking
This commit is contained in:
parent
5c6a0eda3b
commit
20b3c40816
@ -1098,13 +1098,9 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
|
||||
has_query = nsurl_has_component(url, NSURL_QUERY);
|
||||
|
||||
/* Get rid of any url fragment */
|
||||
if (nsurl_has_component(url, NSURL_FRAGMENT)) {
|
||||
error = nsurl_defragment(url, &defragmented_url);
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
} else {
|
||||
defragmented_url = nsurl_ref(url);
|
||||
}
|
||||
error = nsurl_defragment(url, &defragmented_url);
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
|
||||
if (flags & LLCACHE_RETRIEVE_FORCE_FETCH || post != NULL) {
|
||||
/* Create new object */
|
||||
|
@ -1806,14 +1806,9 @@ struct path_data *urldb_add_path(lwc_string *scheme, unsigned int port,
|
||||
free(path_query);
|
||||
|
||||
if (d && !d->url) {
|
||||
/* Insert URL */
|
||||
if (nsurl_has_component(url, NSURL_FRAGMENT)) {
|
||||
nserror err = nsurl_defragment(url, &d->url);
|
||||
if (err != NSERROR_OK)
|
||||
return NULL;
|
||||
} else {
|
||||
d->url = nsurl_ref(url);
|
||||
}
|
||||
/* Insert defragmented URL */
|
||||
if (nsurl_defragment(url, &d->url) != NSERROR_OK)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return d;
|
||||
@ -2728,12 +2723,8 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
|
||||
assert(url && header);
|
||||
|
||||
/* Get defragmented URL, as 'urlt' */
|
||||
if (nsurl_has_component(url, NSURL_FRAGMENT)) {
|
||||
if (nsurl_defragment(url, &urlt) != NSERROR_OK)
|
||||
return NULL;
|
||||
} else {
|
||||
urlt = nsurl_ref(url);
|
||||
}
|
||||
if (nsurl_defragment(url, &urlt) != NSERROR_OK)
|
||||
return NULL;
|
||||
|
||||
scheme = nsurl_get_component(url, NSURL_SCHEME);
|
||||
if (scheme == NULL) {
|
||||
|
@ -1911,6 +1911,15 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag)
|
||||
size_t length;
|
||||
char *pos;
|
||||
|
||||
/* check for source url having no fragment already */
|
||||
if (url->components.fragment == NULL) {
|
||||
*no_frag = (nsurl *)url;
|
||||
|
||||
(*no_frag)->count++;
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* Find the change in length from url to new_url */
|
||||
length = url->length;
|
||||
if (url->components.fragment != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user