diff options
author | VirtualTam <virtualtam@flibidi.net> | 2015-09-08 22:03:18 +0200 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2015-09-08 22:03:18 +0200 |
commit | ce47a75864d7d398a68705df67da2ae00ca89eca (patch) | |
tree | a58c1bcaab33d42161b23d55c739737526ea17e9 /application | |
parent | 0a813cfd7cdf3c81faba8568bf6e2e667aae6f13 (diff) | |
parent | ef591e7ee21435da9314c5f7f6ea983c6f423898 (diff) | |
download | Shaarli-ce47a75864d7d398a68705df67da2ae00ca89eca.tar.gz Shaarli-ce47a75864d7d398a68705df67da2ae00ca89eca.tar.zst Shaarli-ce47a75864d7d398a68705df67da2ae00ca89eca.zip |
Merge pull request #337 from doc75/doublon_url
#325 small enhancement to fix the GetLinkFromUrl method
Diffstat (limited to 'application')
-rw-r--r-- | application/LinkDB.php | 4 | ||||
-rwxr-xr-x | application/Url.php | 30 |
2 files changed, 32 insertions, 2 deletions
diff --git a/application/LinkDB.php b/application/LinkDB.php index 463aa47e..84733505 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php | |||
@@ -287,6 +287,10 @@ You use the community supported version of the original Shaarli project, by Seba | |||
287 | 287 | ||
288 | /** | 288 | /** |
289 | * Returns the link for a given URL, or False if it does not exist. | 289 | * Returns the link for a given URL, or False if it does not exist. |
290 | * | ||
291 | * @param string $url URL to search for | ||
292 | * | ||
293 | * @return mixed the existing link if it exists, else 'false' | ||
290 | */ | 294 | */ |
291 | public function getLinkFromUrl($url) | 295 | public function getLinkFromUrl($url) |
292 | { | 296 | { |
diff --git a/application/Url.php b/application/Url.php index 02a4395d..af43b457 100755 --- a/application/Url.php +++ b/application/Url.php | |||
@@ -26,6 +26,32 @@ function unparse_url($parsedUrl) | |||
26 | } | 26 | } |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * Removes undesired query parameters and fragments | ||
30 | * | ||
31 | * @param string url Url to be cleaned | ||
32 | * | ||
33 | * @return string the string representation of this URL after cleanup | ||
34 | */ | ||
35 | function cleanup_url($url) | ||
36 | { | ||
37 | $obj_url = new Url($url); | ||
38 | return $obj_url->cleanup(); | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * Get URL scheme. | ||
43 | * | ||
44 | * @param string url Url for which the scheme is requested | ||
45 | * | ||
46 | * @return mixed the URL scheme or false if none is provided. | ||
47 | */ | ||
48 | function get_url_scheme($url) | ||
49 | { | ||
50 | $obj_url = new Url($url); | ||
51 | return $obj_url->getScheme(); | ||
52 | } | ||
53 | |||
54 | /** | ||
29 | * URL representation and cleanup utilities | 55 | * URL representation and cleanup utilities |
30 | * | 56 | * |
31 | * Form | 57 | * Form |
@@ -90,7 +116,7 @@ class Url | |||
90 | /** | 116 | /** |
91 | * Returns a string representation of this URL | 117 | * Returns a string representation of this URL |
92 | */ | 118 | */ |
93 | public function __toString() | 119 | public function toString() |
94 | { | 120 | { |
95 | return unparse_url($this->parts); | 121 | return unparse_url($this->parts); |
96 | } | 122 | } |
@@ -149,7 +175,7 @@ class Url | |||
149 | { | 175 | { |
150 | $this->cleanupQuery(); | 176 | $this->cleanupQuery(); |
151 | $this->cleanupFragment(); | 177 | $this->cleanupFragment(); |
152 | return $this->__toString(); | 178 | return $this->toString(); |
153 | } | 179 | } |
154 | 180 | ||
155 | /** | 181 | /** |