Bitbucket: use AJS.contextPath() to build API URLs
Created by: lguychard
When using a context path (https://confluence.atlassian.com/kb/set-a-context-path-for-atlassian-applications-836601189.html), the assumption that the bitbucket API is at ${window.location.origin}/rest/api
is broken.
This introduces a fix by using the global AJS.contextPath()
when available.
Since browser extension content scripts cannot access the page's global scope, this currently only works in the native integration. I'm a bit reluctant to use the "usual hacks" to access AJS.contextPath()
from the browser extension content script (eg. script tag injection + communicating the value through data attributes or custom events), and have left the window.location.origin
fallback in place when AJS
is undefined. Thoughts?