Changeset 20533
- Timestamp:
- 10/02/08 23:45:03 (3 months ago)
- Location:
- lang/php/Scraper
- Files:
-
- 3 modified
-
library/Diggin/Scraper/Strategy/Flexible.php (modified) (1 diff)
-
library/Diggin/Uri/Http.php (modified) (3 diffs)
-
tests/Diggin/Uri/HttpTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/php/Scraper/library/Diggin/Scraper/Strategy/Flexible.php
r20204 r20533 100 100 protected static function _xpathOrCss2Xpath($exp){ 101 101 if (preg_match('!^(?:/|id\()!', $exp)) { 102 return $exp;102 return '.'.$exp; 103 103 } else { 104 104 if ($exp === '.') { -
lang/php/Scraper/library/Diggin/Uri/Http.php
r20204 r20533 15 15 */ 16 16 17 /** 18 * Utils For Http 19 */ 17 20 class Diggin_Uri_Http 18 21 { … … 35 38 } else { 36 39 if (strpos(pathinfo(parse_url($base_url, PHP_URL_PATH), PATHINFO_DIRNAME), '/') === false) { 37 return http_build_url($base_url, array("path" => $url ,),40 return http_build_url($base_url, array("path" => $url), 38 41 HTTP_URL_STRIP_QUERY | HTTP_URL_STRIP_FRAGMENT); 39 42 } else { 40 return http_build_url($base_url, array("path" => $url ,),43 return http_build_url($base_url, array("path" => $url), 41 44 HTTP_URL_JOIN_PATH | HTTP_URL_STRIP_QUERY | HTTP_URL_STRIP_FRAGMENT); 42 45 } … … 44 47 //Net_URL2 ver 0.2.0 45 48 } else { 46 if (!class_exists('Net_URL2')) require_once 'Net/URL2.php'; 49 if (!class_exists('Net_URL2')) require_once 'Net/URL2.php'; 50 static $neturl2; 47 51 $neturl2 = new Net_URL2($base_url); 48 return $neturl2->resolve( $url)->getUrl();49 } 52 return $neturl2->resolve(str_replace(chr(32), '%20', $url))->getUrl(); 53 } 50 54 } 51 55 } -
lang/php/Scraper/tests/Diggin/Uri/HttpTest.php
r20321 r20533 40 40 * check getting absoluteUrl 41 41 * 42 *43 * import from rhaco's doc-test44 * @see http://rhaco.googlecode.com/svn/trunk/1_6_1/network/Url.php45 42 */ 46 43 public function testGetAbsoluteUrl() 47 44 { 45 //if 46 $this->assertEquals('http://yahoo.com/test/', 47 $this->object->getAbsoluteUrl('http://yahoo.com/test/', 'http://www.rhaco.org/')); 48 49 // import from rhaco's doc-test 50 // @see http://rhaco.googlecode.com/svn/trunk/1_6_1/network/Url.php 48 51 $this->assertEquals('http://www.rhaco.org/doc/ja/index.html', 49 52 $this->object->getAbsoluteUrl('/doc/ja/index.html', 'http://www.rhaco.org/')); … … 70 73 $this->assertEquals('http://www.rhaco.org/index.html', 71 74 $this->object->getAbsoluteUrl('/index.html', 'http://www.rhaco.org/doc/ja')); 75 76 //@see http://d.hatena.ne.jp/kitamomonga/20080410/ruby_mechanize_percent_url_bug 77 $this->assertEquals('http://test.org/doc/ja/index.cgi?param=hoge', 78 $this->object->getAbsoluteUrl('?param=hoge', 'http://test.org/doc/ja/index.cgi?test=bar')); 79 $this->assertEquals('http://test.org/index.php?param=hoge', 80 $this->object->getAbsoluteUrl('?param=hoge', 'http://test.org/index.php')); 81 //if space, 82 $this->assertEquals('http://www.rhaco.org/doc/ja/'.rawurlencode('test space.html'), 83 $this->object->getAbsoluteUrl('test space.html', 'http://www.rhaco.org/doc/ja/')); 84 72 85 } 73 86 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)