#microformats 2019-08-16

2019-08-16 UTC
mauz555, [tantek], [Rose], [prtksxna], [jgmac1106], janttoDiscord[m], willibuddyDiscor, [KevinMarks], [grantcodes], IWSlackGateway and [jgarber] joined the channel
#
[jgarber]
I suspect I know the answer, but is there consensus (both in specs and in implementations) that a normalized absolute URL of `https://example.com` is `https://example.com/` ?
#
[jgarber]
☝ Important difference being the trailing slash in the normalized URL.
#
aaronpk
If you want the URL to represent a document fetched from that address then yes it needs the slash, because you can't make an HTTP request with no path
#
[jgarber]
Looking at http://microformats.org/wiki/microformats2-parsing, the “parsing a u- property” includes the following:
#
[jgarber]
The examples on the wiki (and in the test suite repo https://github.com/microformats/tests), _do not_ add a trailing slash in the resulting JSON when none is present in the HTML (e.g. `https://example.com` in the HTML is `https://example.com` in the JSON).
#
[jgarber]
> return the normalized absolute URL of the gotten value, following the containing document’s language’s rules for resolving relative URLs (e.g. in HTML, use the current URL context as determined by the page, and first <base> element, if any).
#
[jgarber]
…and I’m wondering if that’s accurate or if the “normalized absolute URL of the gotten value” in the text above is being misinterpreted in examples, parsers, etc.
#
aaronpk
Hm I don't know what the intent is there. It'd certainly be easier for me to consume if the parser added the slash. I have code that does that in most of my projects
#
sknebel
check what the parsers do already
#
sknebel
I suspect they add the slash already
#
aaronpk
PHP does not
#
aaronpk
tho it does if the href attribute is ""
#
sknebel
hm, actually not sure with others either
#
sknebel
I think python also has some exceptions
#
sknebel
only doing url parsing if it is looking at relative stuff
#
sknebel
(url parsing is also not the fastest thing to do, but I don't remember numbers)
#
[jgarber]
The Ruby microformats parser does not and the generic microformats test suite follows the wiki (which does not add trailing slash in the examples).
[tantek], [KevinMarks], [Lewis_Cowles], [mapkyca], [fluffy] and [jgarber] joined the channel
#
[jgarber]
Are there any opinions on how parsers should normalize absolute URLs of kind `https://example.com` ?
#
[jgarber]
At least one Ruby URL parser (Addressable) has a normalize method that results in `https://example.com/`.
#
[jgarber]
I’m partial to “normalized absolute URL” including the trailing slash when the URL is of kind `https://example.com`.
#
aaronpk
i'm trying to imagine a situation in which that would cause errors, but I can't think of any
#
[jgarber]
Real world _probably_ wouldn’t cause errors.
#
[jgarber]
We’d need to update the wiki, the test suite, and parsers may need updating, though.
#
sknebel
although real-world situations where not having it causes errors likely are also fairly rare - and you have to expect weird output from the parsers, since they'll pass through unfixable inputs - at least that was the answer last time "how to handle an unparsable URL" was raised
#
aaronpk
i'm thinking things like URL comparisons for representative h-card and such
#
aaronpk
and those all need to be normalized to include the / when comparing anyway
#
sknebel
good example, yes
#
[jgarber]
Right. The IndieAuth spec, when defining profile URLs, etc., clearly states that the trailing slash (in this precise example) constitutes a valid profile URL (whereas a URL lacking the trailing slash _does not_).
#
[jgarber]
☝ If we’re looking for other similar documented cases.
#
[jgarber]
If there’s enough consensus, I’m happy to open up a PR on the microformats/tests suite that adds the necessary slashes in the expected output JSON (while intentionally _not_ updating the input HTML). Not sure I’d be able to update all the pages on the wiki, though. 😂
[tonz], kev1, [aarongustafson], [tantek], [Lewis_Cowles], [jgarber], [jgmac1106], [manton], [Rose] and [KevinMarks] joined the channel