The code was fixing links in the whole document, not only in the subtree
you were including.
The problem lay somewhere else in the file, in the "* Hey! I have a link
[[https://example.org][here]] (Awesome!)" headline.
There, `org-element-context' needed to check the headline, by (looking-at
org-complex-heading-regexp). However, since the changes were happening in Fundamental mode, the regexp was not set. Hence the error.
So, the fix implements the following changes:
- only modify links withing the included part of the document,
- do not modify anything if includer and includee both live in the same
directory,
- switch to Org mode before proceeding with changes.
Kaushal Modi