[RN] Remove unncessary characters from the invite URL
This commit is contained in:
parent
caea02a322
commit
1748049322
|
@ -35,10 +35,21 @@ export function getURLWithoutParams(url: URL): URL {
|
||||||
const { hash, search } = url;
|
const { hash, search } = url;
|
||||||
|
|
||||||
if ((hash && hash.length > 1) || (search && search.length > 1)) {
|
if ((hash && hash.length > 1) || (search && search.length > 1)) {
|
||||||
// eslint-disable-next-line no-param-reassign
|
url = new URL(url.href); // eslint-disable-line no-param-reassign
|
||||||
url = new URL(url.href);
|
|
||||||
url.hash = '';
|
url.hash = '';
|
||||||
url.search = '';
|
url.search = '';
|
||||||
|
|
||||||
|
// XXX The implementation of URL at least on React Native appends ? and
|
||||||
|
// # at the end of the href which is not desired.
|
||||||
|
let { href } = url;
|
||||||
|
|
||||||
|
if (href) {
|
||||||
|
href.endsWith('#') && (href = href.substring(0, href.length - 1));
|
||||||
|
href.endsWith('?') && (href = href.substring(0, href.length - 1));
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
url.href === href || (url = new URL(href));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
|
|
Loading…
Reference in New Issue