9

Who knew that NOT using results given from an API can actually help.

The private devRant APIs give you offsets in text of where links are in comments and in rants.

It’s EXTREMELY inaccurate and I don’t understand why it’s so hard to write it so it’s accurate 100% of the time.

So I said fuck it and NOT use the given offsets and just hard-find using the built-in algorithms inside Swift to create the range for me. Results? It works 100% of the time. No crashes, no out-of-range errors, no nothing.

Comments
  • 2
    If it works on devRant, then it's not the APIs fault, right?
  • 8
    Could it be a problem with UTF-8 and multi-byte characters? Offset could be in bytes or in characters, after all?
  • 2
    @Fast-Nop wait shit, that might be it.

    Working with text in any PL is a truly terrible experience, shit.
  • 3
    @ScriptCoded it works on devRant because it’s his API and he know it inside and out. The API is private and it has no explanation for many many many things. I wouldn’t know and everything is a guess when you revers-engineer this thing.
  • 2
    @OmerFlame Exactly, that time you got it right. It's not meant to be used publicly in the first place. dR has no obligation to make it work outside the scope of the official app, so perhaps "wtf dfox" isn't very fair.
  • 1
    @Fast-Nop
    Obviously, text offsets should be in grapheme clusters...
  • 1
    @Oktokolo Didn't know about em. Cool stuff.
  • 1
    @ScriptCoded the “wtf dfox” is a total joke lol, I just wondered to myself what he did because I just couldn’t find what the discrepancy was.
Add Comment