Not sure what the error is, but I can tell you it will be in this file
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/click-track.js.es6
And any changes you would need to make to that to support the different protocol, or tell it to skip click-tracking all together would likely be accepted in Core.
I think if you right-click and choose open in New Tab/Window, the link should work and skip click-track (again, I think). I know that isn’t the most feasible, but just something to keep in mind.
Actually thinking through this, if you change your generated link to also have the class of hljs-title no-track-link
, it should solve your problem.