Prefer URL constructor over url
dependency
This commit is contained in:
parent
9d45a3760f
commit
3b13eb7b44
3 changed files with 3 additions and 16 deletions
|
@ -14,11 +14,8 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import url from 'url';
|
||||
|
||||
import SdkConfig from '../SdkConfig';
|
||||
import { MatrixClientPeg } from '../MatrixClientPeg';
|
||||
import { urlSearchParamsToObject } from "./UrlUtils";
|
||||
|
||||
export function getHostingLink(campaign) {
|
||||
const hostingLink = SdkConfig.get().hosting_signup_link;
|
||||
|
@ -28,11 +25,8 @@ export function getHostingLink(campaign) {
|
|||
if (MatrixClientPeg.get().getDomain() !== 'matrix.org') return null;
|
||||
|
||||
try {
|
||||
const hostingUrl = url.parse(hostingLink);
|
||||
const params = urlSearchParamsToObject(new URLSearchParams(hostingUrl.query));
|
||||
params.utm_campaign = campaign;
|
||||
hostingUrl.search = undefined;
|
||||
hostingUrl.query = params;
|
||||
const hostingUrl = new URL(hostingLink);
|
||||
hostingUrl.searchParams.set("utm_campaign", campaign);
|
||||
return hostingUrl.format();
|
||||
} catch (e) {
|
||||
return hostingLink;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue