/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';
import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
import RNTesterText from '../../components/RNTesterText';
import React from 'react';
import {StyleSheet, View} from 'react-native';
type Props = {
url: string,
};
function URLComponent(props: Props) {
const parsedUrl = new URL(props.url);
return (
{`href: ${parsedUrl.href}`}
{`hash: ${parsedUrl.hash}`}
{`host: ${parsedUrl.host}`}
{`hostname: ${parsedUrl.hostname}`}
{`password: ${parsedUrl.password}`}
{`username: ${parsedUrl.username}`}
{`pathname: ${parsedUrl.pathname}`}
{`protocol: ${parsedUrl.protocol}`}
{`toString: ${parsedUrl.toString()}`}
{`port: ${parsedUrl.port}`}
{`search: ${parsedUrl.search}`}
{`searchParams: ${parsedUrl.searchParams.toString()}`}
);
}
const styles = StyleSheet.create({
container: {
padding: 10,
},
});
exports.title = 'URL';
exports.category = 'Basic';
exports.description = 'URL Parameters test';
exports.examples = [
{
title: 'completeURL',
description: 'URL with username,password,port,and queryparams',
render(): React.Node {
return (
);
},
},
{
title: 'basicURL',
description: 'Basic URL without username, password, or port',
render(): React.Node {
return ;
},
},
{
title: 'queryParamsURL',
description: 'URL with query parameters',
render(): React.Node {
return (
);
},
},
{
title: 'authAndPortURL',
description: 'URL with username, password, and port',
render(): React.Node {
return (
);
},
},
] as Array;