This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +3
-16
lines changed Expand file tree Collapse file tree 3 files changed +3
-16
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ import _linkifyElement from 'linkifyjs/element';
2525import _linkifyString from 'linkifyjs/string' ;
2626import classNames from 'classnames' ;
2727import EMOJIBASE_REGEX from 'emojibase-regex' ;
28- import url from 'url' ;
2928import katex from 'katex' ;
3029import { AllHtmlEntities } from 'html-entities' ;
3130import { IContent } from 'matrix-js-sdk/src/models/event' ;
@@ -153,10 +152,8 @@ export function getHtmlText(insaneHtml: string): string {
153152 */
154153export function isUrlPermitted ( inputUrl : string ) : boolean {
155154 try {
156- const parsed = url . parse ( inputUrl ) ;
157- if ( ! parsed . protocol ) return false ;
158155 // URL parser protocol includes the trailing colon
159- return PERMITTED_URL_SCHEMES . includes ( parsed . protocol . slice ( 0 , - 1 ) ) ;
156+ return PERMITTED_URL_SCHEMES . includes ( new URL ( inputUrl ) . protocol . slice ( 0 , - 1 ) ) ;
160157 } catch ( e ) {
161158 return false ;
162159 }
Original file line number Diff line number Diff line change @@ -14,11 +14,8 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import url from 'url' ;
18-
1917import SdkConfig from '../SdkConfig' ;
2018import { MatrixClientPeg } from '../MatrixClientPeg' ;
21- import { urlSearchParamsToObject } from "./UrlUtils" ;
2219
2320export function getHostingLink ( campaign ) {
2421 const hostingLink = SdkConfig . get ( ) . hosting_signup_link ;
@@ -28,11 +25,8 @@ export function getHostingLink(campaign) {
2825 if ( MatrixClientPeg . get ( ) . getDomain ( ) !== 'matrix.org' ) return null ;
2926
3027 try {
31- const hostingUrl = url . parse ( hostingLink ) ;
32- const params = urlSearchParamsToObject ( new URLSearchParams ( hostingUrl . query ) ) ;
33- params . utm_campaign = campaign ;
34- hostingUrl . search = undefined ;
35- hostingUrl . query = params ;
28+ const hostingUrl = new URL ( hostingLink ) ;
29+ hostingUrl . searchParams . set ( "utm_campaign" , campaign ) ;
3630 return hostingUrl . format ( ) ;
3731 } catch ( e ) {
3832 return hostingLink ;
Original file line number Diff line number Diff line change @@ -16,10 +16,6 @@ limitations under the License.
1616
1717import * as url from "url" ;
1818
19- export function urlSearchParamsToObject < T extends { } > ( params : URLSearchParams ) {
20- return < T > Object . fromEntries ( [ ...params . entries ( ) ] ) ;
21- }
22-
2319/**
2420 * If a url has no path component, etc. abbreviate it to just the hostname
2521 *
You can’t perform that action at this time.
0 commit comments