Merge pull request #3327 from matrix-org/travis/discover-terms

Handle terms agreement in Discovery section of user settings
This commit is contained in:
Travis Ralston 2019-08-21 10:14:45 -06:00 committed by GitHub
commit 04bb2ed322
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 317 additions and 50 deletions

View file

@ -25,38 +25,7 @@ import dis from "../../../dispatcher";
import { getThreepidBindStatus } from '../../../boundThreepids';
import IdentityAuthClient from "../../../IdentityAuthClient";
import {SERVICE_TYPES} from "matrix-js-sdk";
/**
* If a url has no path component, etc. abbreviate it to just the hostname
*
* @param {string} u The url to be abbreviated
* @returns {string} The abbreviated url
*/
function abbreviateUrl(u) {
if (!u) return '';
const parsedUrl = url.parse(u);
// if it's something we can't parse as a url then just return it
if (!parsedUrl) return u;
if (parsedUrl.path == '/') {
// we ignore query / hash parts: these aren't relevant for IS server URLs
return parsedUrl.host;
}
return u;
}
function unabbreviateUrl(u) {
if (!u) return '';
let longUrl = u;
if (!u.startsWith('https://')) longUrl = 'https://' + u;
const parsed = url.parse(longUrl);
if (parsed.hostname === null) return u;
return longUrl;
}
import {abbreviateUrl, unabbreviateUrl} from "../../../utils/UrlUtils";
/**
* Check an IS URL is valid, including liveness check