diff options
author | Xan Lopez <xan@gnome.org> | 2009-08-10 18:38:00 +0800 |
---|---|---|
committer | Xan Lopez <xan@gnome.org> | 2009-08-10 18:38:00 +0800 |
commit | 44706a1d0bc863eb6ffd9e14a207c230e9d3a028 (patch) | |
tree | 0da2158bb114f8008c02eff2cd13e01d437bff12 | |
parent | cc3b8a8703c4ace932dc31680bbb0c3d1ce4829a (diff) | |
download | gsoc2013-epiphany-44706a1d0bc863eb6ffd9e14a207c230e9d3a028.tar gsoc2013-epiphany-44706a1d0bc863eb6ffd9e14a207c230e9d3a028.tar.gz gsoc2013-epiphany-44706a1d0bc863eb6ffd9e14a207c230e9d3a028.tar.bz2 gsoc2013-epiphany-44706a1d0bc863eb6ffd9e14a207c230e9d3a028.tar.lz gsoc2013-epiphany-44706a1d0bc863eb6ffd9e14a207c230e9d3a028.tar.xz gsoc2013-epiphany-44706a1d0bc863eb6ffd9e14a207c230e9d3a028.tar.zst gsoc2013-epiphany-44706a1d0bc863eb6ffd9e14a207c230e9d3a028.zip |
Move URL normalization into a utility function
-rw-r--r-- | embed/ephy-embed-utils.c | 15 | ||||
-rw-r--r-- | embed/ephy-embed-utils.h | 5 | ||||
-rw-r--r-- | src/ephy-link.c | 21 |
3 files changed, 23 insertions, 18 deletions
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c index a5c77a782..0405de744 100644 --- a/embed/ephy-embed-utils.c +++ b/embed/ephy-embed-utils.c @@ -95,3 +95,18 @@ ephy_embed_utils_address_has_web_scheme (const char *address) return has_web_scheme; } + +char* +ephy_embed_utils_normalize_address (const char *address) +{ + char *effective_address; + + g_return_val_if_fail (address, NULL); + + if (ephy_embed_utils_address_has_web_scheme (address) == FALSE) + effective_address = g_strconcat ("http://", address, NULL); + else + effective_address = g_strdup (address); + + return effective_address; +} diff --git a/embed/ephy-embed-utils.h b/embed/ephy-embed-utils.h index fa226d0d7..5d82171e9 100644 --- a/embed/ephy-embed-utils.h +++ b/embed/ephy-embed-utils.h @@ -41,8 +41,9 @@ G_BEGIN_DECLS #define EPHY_WEBKIT_BACK_FORWARD_LIMIT 100 -char * ephy_embed_utils_link_message_parse (char *message); -gboolean ephy_embed_utils_address_has_web_scheme (const char *address); +char* ephy_embed_utils_link_message_parse (char *message); +gboolean ephy_embed_utils_address_has_web_scheme (const char *address); +char* ephy_embed_utils_normalize_address (const char *address); G_END_DECLS diff --git a/src/ephy-link.c b/src/ephy-link.c index 7845dfb62..d6b226d65 100644 --- a/src/ephy-link.c +++ b/src/ephy-link.c @@ -89,28 +89,17 @@ ephy_link_open (EphyLink *link, EphyLinkFlags flags) { EphyEmbed *new_embed = NULL; - char *effective_url = NULL; - - /* - * WebKit does not normalize URI's by itself, so we need to - * handle this ourselves - */ - if (ephy_embed_utils_address_has_web_scheme (address) == FALSE) - { - effective_url = g_strconcat ("http://", address, NULL); - } - else - { - effective_url = g_strdup (address); - } + char *effective_address; LOG ("ephy_link_open address \"%s\" parent-embed %p flags %u", address, embed, flags); + effective_address = ephy_embed_utils_normalize_address (address); + g_signal_emit (link, signals[OPEN_LINK], 0, - effective_url, embed, flags, + effective_address, embed, flags, &new_embed); - g_free (effective_url); + g_free (effective_address); return new_embed; } |