Permalink
Browse files

Applying fix from 'euromark' to fix protocol relative links

Fixes #2107
  • Loading branch information...
1 parent 924fb6f commit 5ee09eb27e8463ce561847e3437a0f542f6719cb @markstory markstory committed Oct 18, 2011
Showing with 14 additions and 1 deletion.
  1. +1 −1 cake/libs/router.php
  2. +13 −0 cake/tests/cases/libs/router.test.php
View
@@ -853,7 +853,7 @@ function url($url = null, $full = false) {
}
$output = str_replace('//', '/', $base . '/' . $output);
} else {
- if (((strpos($url, '://')) || (strpos($url, 'javascript:') === 0) || (strpos($url, 'mailto:') === 0)) || (!strncmp($url, '#', 1))) {
+ if (((strpos($url, '://')) !== false || (strpos($url, 'javascript:') === 0) || (strpos($url, 'mailto:') === 0)) || (!strncmp($url, '#', 1))) {
return $url;
}
if (empty($url)) {
@@ -2535,6 +2535,19 @@ function testMatchWithPatterns() {
}
/**
+ * Test protocol relative urls.
+ *
+ * @return void
+ */
+ function testProtocolUrls() {
+ $url = 'svn+ssh://example.com';
+ $this->assertEqual($url, Router::url($url));
+
+ $url = '://example.com';
+ $this->assertEqual($url, Router::url($url));
+ }
+
+/**
* test that patterns work for :action
*
* @return void

0 comments on commit 5ee09eb

Please sign in to comment.