Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { View } from 'react-native';

import Icon, {
Expand All @@ -16,16 +16,18 @@ interface DisplayURLProps {
}

const DisplayURL = ({ url }: DisplayURLProps) => {
let urlObject;

try {
urlObject = new URL(url);
} catch (e) {
// eslint-disable-next-line no-console
Logger.error(e as Error, `DisplayURL: new URL(url) cannot parse ${url}`);
}

const isHTTP = urlObject?.protocol === 'http:';
const [isHTTP, setIsHTTP] = useState(false);

useEffect(() => {
let urlObject;
try {
urlObject = new URL(url);
} catch (e) {
// eslint-disable-next-line no-console
Logger.error(e as Error, `DisplayURL: new URL(url) cannot parse ${url}`);
}
setIsHTTP(urlObject?.protocol === 'http:');
}, [url]);

const urlWithoutProtocol = url?.replace(/https?:\/\//u, '');

Expand Down
Loading