summaryrefslogtreecommitdiff
path: root/utils/nsurl.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-10-24 18:22:45 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2012-10-24 18:22:45 +0100
commita526209e747642c9dbd8c0cbe9ec2b5247c35d5e (patch)
treeccbcffa6952976c8c3f0a887c0f9e450de99bf7d /utils/nsurl.c
parent719a36972b60165fc45b956703a4860855145548 (diff)
downloadnetsurf-a526209e747642c9dbd8c0cbe9ec2b5247c35d5e.tar.gz
netsurf-a526209e747642c9dbd8c0cbe9ec2b5247c35d5e.tar.bz2
More useful title info for images.
Diffstat (limited to 'utils/nsurl.c')
-rw-r--r--utils/nsurl.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 47b7f5451..8c525452a 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1564,6 +1564,38 @@ const char *nsurl_access(const nsurl *url)
/* exported interface, documented in nsurl.h */
+const char *nsurl_access_leaf(const nsurl *url)
+{
+ size_t path_len;
+ const char *path;
+ const char *leaf;
+
+ if (url->components.path == NULL)
+ return "";
+
+ path = lwc_string_data(url->components.path);
+ path_len = lwc_string_length(url->components.path);
+
+ if (path_len == 0)
+ return "";
+
+ if (path_len == 1 && *path == '/')
+ return "/";
+
+ leaf = path + path_len;
+
+ do {
+ leaf--;
+ } while ((leaf != path) && (*leaf != '/'));
+
+ if (*leaf == '/')
+ leaf++;
+
+ return leaf;
+}
+
+
+/* exported interface, documented in nsurl.h */
size_t nsurl_length(const nsurl *url)
{
assert(url != NULL);