forked from abcdlzy/PHPProxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request abcdlzy#6 from PandaShare/develop
修改了 fix_request_url 的逻辑
- Loading branch information
Showing
3 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
$list = array( | ||
'http://normal.com', | ||
'https://normals.com', | ||
'http:////a.com/', | ||
'https:////a.com////', | ||
'http:/a.com//////', | ||
'http://normal.com/test/page.html', | ||
'https://normals.com/test/page.html?req=hello', | ||
'http:////a.com/test/123/page/__f.aspx?req=test', | ||
'https:////a.com////test/123/page/__f.aspx?req=test', | ||
'http:/a.com//////test/123/page/__f.aspx?req=test', | ||
); | ||
|
||
function formatURL($url) { | ||
if (empty($url)) return ''; | ||
$url_detail = array(); | ||
$url = urldecode($url); | ||
if (!preg_match('/^(https|http):\/{0,}(.*)$/', $url, $url_detail) || count($url_detail) != 3) return ''; | ||
$url = $url_detail[1] . '://' . preg_replace('/\/{2,}/', '/', $url_detail[2]); | ||
return $url; | ||
} | ||
|
||
foreach ($list as $val) { | ||
foreach ($list as $val) { | ||
echo | ||
'origin : ' . $val . '<br />' . | ||
'new : ' . formatURL($val) . '<br />'; | ||
|
||
$encode = urlencode($val); | ||
echo | ||
'origin : ' . $encode . '<br />' . | ||
'new : ' . formatURL($encode) . '<br />'; | ||
|
||
echo '<br /><br /><br /><br /><br /><br />'; | ||
} | ||
} | ||
?> |