Day 3: relative urls
Today I started with fiddling with reply-contexts, but that turned out to be a giant mess, because I store my own posts in a different format than posts by others, and I wanted to re-use my template. I need to come back to that another time.
Yesterday, I mentioned Martijn in my post. And when I mention urls in my posts, my server will try to notify the other site that I mentioned that page. So yesterday my site notified Martijn’s site. At least, it tried.
Martijn is known for giving parsers a hard time. My site came up with http://vanderven.se/mention.php
as his webmention endpoint, which is not correct. The following things went wrong:
- I mentioned
http://vanderven.se/martijn
, which is not his canonical url. That’shttp://vanderven.se/martijn/
, ending in a/
. - Kirby Toolkit’s
remote::get()
, which I used to fetch the page, did follow the redirect, but my script didn’t update the mentioned url accordingly. Since Martijns endpoint link is relative (webmention.php
), that/
does matter: it defines Martijns page as a folder, so his endpoint is athttp://vanderven.se/martijn/endpoint.php
- Finally, it turned out that Kirby Toolkit’s
url::makeAbsolute($path, $home)
did not handle relative urls well. It just intelligently added $path to $home, but didn’t actually solve relative urls where $home is a folder or file.
Martijn encouraged me to write some tests for Kirby Toolkit, because they use phpunit
and all that stuff. It was nice, because I didn’t have any experience with this kind of testing (I just refresh the page and hope it works). Learning to test things is a goal for 2017 for me.
When I had a list of good tests, I started to change the function. I might be a little too refresh-frenzy still, but in the end I managed to pass all my own tests. After the pull request and with a little tweaking of my own scripts, I finally got Martijn’s endpoint:
So, Martijn, here is another try, still without your canonical /
, just to see if it works now. :)