iop-alliance / okh-search

A self-hostable, federated search for open source hardware
https://search.openknowhow.org
MIT License
10 stars 9 forks source link

Allow "blob" links for images #16

Open julianstirling opened 4 years ago

julianstirling commented 4 years ago

It seems that a few manifests are failing because the link is to the github or gitlab blob not to the raw. While it is technically not our problem, we could simply fix this with 1 regex

^(https:\/\/git(?:hub|lab).com\/.*\/)blob(\/.*)$

And then if it matches then instead have the link be:

\1raw\2

where \1 and \2 are the regex groups 1 and 2. I would put in a merge request but I don't properly understand javascript.

kasbah commented 4 years ago

We could do it, but then we make it our responsibility. We do it for Kitspace readmes but it's a pain to maintain (though it's more complicated because of the way relative links from readmes work). I am really not sure we should be encoding platform quirks into our implementation of a standard. What it means is we are making things more complicated for everyone that wants to crawl manifests.

Putting my QA engineer hat on your regex will probably fail if someone decides to calls their project blob or makes a branch called blob.

“A QA engineer walks into a bar. Orders a beer. Orders 0 beers. Orders 999999999 beers. Orders a lizard. Orders -1 beers. Orders a sfdeljknesv.”

kasbah commented 4 years ago

Though your regex is actually a bit better than what we had on Kitspace before, so I stole it.