mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 12:12:35 +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);
|
has_query = nsurl_has_component(url, NSURL_QUERY);
|
||||||
|
|
||||||
/* Get rid of any url fragment */
|
/* Get rid of any url fragment */
|
||||||
if (nsurl_has_component(url, NSURL_FRAGMENT)) {
|
error = nsurl_defragment(url, &defragmented_url);
|
||||||
error = nsurl_defragment(url, &defragmented_url);
|
if (error != NSERROR_OK)
|
||||||
if (error != NSERROR_OK)
|
return error;
|
||||||
return error;
|
|
||||||
} else {
|
|
||||||
defragmented_url = nsurl_ref(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & LLCACHE_RETRIEVE_FORCE_FETCH || post != NULL) {
|
if (flags & LLCACHE_RETRIEVE_FORCE_FETCH || post != NULL) {
|
||||||
/* Create new object */
|
/* Create new object */
|
||||||
|
@ -1806,14 +1806,9 @@ struct path_data *urldb_add_path(lwc_string *scheme, unsigned int port,
|
|||||||
free(path_query);
|
free(path_query);
|
||||||
|
|
||||||
if (d && !d->url) {
|
if (d && !d->url) {
|
||||||
/* Insert URL */
|
/* Insert defragmented URL */
|
||||||
if (nsurl_has_component(url, NSURL_FRAGMENT)) {
|
if (nsurl_defragment(url, &d->url) != NSERROR_OK)
|
||||||
nserror err = nsurl_defragment(url, &d->url);
|
return NULL;
|
||||||
if (err != NSERROR_OK)
|
|
||||||
return NULL;
|
|
||||||
} else {
|
|
||||||
d->url = nsurl_ref(url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
@ -2728,12 +2723,8 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
|
|||||||
assert(url && header);
|
assert(url && header);
|
||||||
|
|
||||||
/* Get defragmented URL, as 'urlt' */
|
/* Get defragmented URL, as 'urlt' */
|
||||||
if (nsurl_has_component(url, NSURL_FRAGMENT)) {
|
if (nsurl_defragment(url, &urlt) != NSERROR_OK)
|
||||||
if (nsurl_defragment(url, &urlt) != NSERROR_OK)
|
return NULL;
|
||||||
return NULL;
|
|
||||||
} else {
|
|
||||||
urlt = nsurl_ref(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
scheme = nsurl_get_component(url, NSURL_SCHEME);
|
scheme = nsurl_get_component(url, NSURL_SCHEME);
|
||||||
if (scheme == NULL) {
|
if (scheme == NULL) {
|
||||||
|
@ -1911,6 +1911,15 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag)
|
|||||||
size_t length;
|
size_t length;
|
||||||
char *pos;
|
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 */
|
/* Find the change in length from url to new_url */
|
||||||
length = url->length;
|
length = url->length;
|
||||||
if (url->components.fragment != NULL) {
|
if (url->components.fragment != NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user