I have unexpected resultes while generating absolute path from relative
php version 5.5.9
$base_url = 'http://www.example.com/img';
$url = 'large/myimage.png';
$result_url = http_request_create_absolute_url($url, $base_url);
print $result_url; // http://www.example.com/large/myimage.png
// expect http://www.example.com/large/myimage.png
$base_url = 'http://www.example.com/files/img/';
$url = 'myimage.png';
$result_url = http_request_create_absolute_url($url, $base_url);
print $result_url; // http://www.example.com/files/myimage.png
// expect http://www.example.com/files/img/myimage.png
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 2584443-9.patch | 10.13 KB | nikolay shapovalov |
Comments
Comment #2
nikolay shapovalov commentedComment #3
nikolay shapovalov commentedComment #4
nikolay shapovalov commentedComment #5
nikolay shapovalov commentedComment #6
nikolay shapovalov commentedComment #7
nikolay shapovalov commentedComment #8
nikolay shapovalov commentedComment #9
nikolay shapovalov commentedAdd tests.
Make functions results more expected.
If you still have questions, just look '/tests/http_request.test', after patch apply.
If somebody can add more test-cases, it would be great.
Comment #10
nikolay shapovalov commentedComment #11
nikolay shapovalov commentedComment #12
megachrizAre you using this function directly? I haven't examined the changes deeply yet, but I wonder if it could break any existing workflows. Well, I should find time to take a closer look at it.
Comment #13
nikolay shapovalov commentedYes I am, and also some contrib modules use this function: Feeds Crawler.
I hope not, all test are passed.
I think most easy way to see difference, run tests from the patch for curent version in 7.x-2.x and this patched version.
But there are some more bugs/features. I not sure about them. But I think if we wouldn't fix them, it's better to update comment for this function.
Comment #15
megachrizI've taken a closer look, especially at the tests. The expected output of each assertion made sense to me, so I went ahead and committed your changes! I did make a few changes to your patch, namely some spelling in the code comments and in the test I changed the key for each expected result from "result" to "expected". Lastly, I changed the
t()call in the test to aformat_string()call. Assert messages in tests don't have to be translated.Thanks for your contribution!