Generate proxy URLs with complex path

This commit is contained in:
Yarmo Mackenbach 2021-03-05 15:11:13 +01:00
parent f68b9b4160
commit 441655ac1e
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1

View file

@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const generateProxyURL = (type, url, opts) => { const generateProxyURL = (type, urlElements, opts) => {
if (!opts || !opts.doipProxyHostname) { if (!opts || !opts.doipProxyHostname) {
return null return null
} }
@ -21,9 +21,16 @@ const generateProxyURL = (type, url, opts) => {
if (type == 'xmpp') { if (type == 'xmpp') {
addParam += '/DESC' addParam += '/DESC'
} }
if (!Array.isArray(urlElements)) {
urlElements = [urlElements]
}
urlElements.map((x) => { encodeURIComponent(x) })
return `https://${ return `https://${
opts.doipProxyHostname opts.doipProxyHostname
}/api/1/get/${type}/${encodeURIComponent(url)}${addParam}` }/api/1/get/${type}/${urlElements.join('/')}${addParam}`
} }
const generateClaim = (fingerprint, format) => { const generateClaim = (fingerprint, format) => {