如何根据当前URL指定HTTP或HTTPS

How do I specify HTTP or HTTPS dependent on the current URL?

本文关键字:指定 HTTP HTTPS URL 何根      更新时间:2023-09-26

我的代码指定

this._restUrl = "http://" + this._info.host + "/app/rest/"; 

问题是我不知道如何使它使用"https://"时使用SSL。如何将其转换为http或https语句?

你可以使用一个相对的协议:

this._restUrl = "//" + this._info.host + "/app/rest/";