mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49:28 -07:00
Generate proxy URLs with complex path
This commit is contained in:
parent
f68b9b4160
commit
441655ac1e
1 changed files with 9 additions and 2 deletions
11
src/utils.js
11
src/utils.js
|
@ -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) => {
|
||||||
|
|
Loading…
Reference in a new issue