Makes components itteratable

This commit is contained in:
Alicia Sykes
2023-06-28 05:57:50 +01:00
parent 595a6833db
commit c83419cfd2
11 changed files with 54 additions and 126 deletions

View File

@@ -140,9 +140,9 @@ export type Cookie = {
attributes: Record<string, string>;
};
export const parseCookies = (cookiesHeader: string): Cookie[] => {
if (!cookiesHeader) return [];
return cookiesHeader.split(/,(?=\s[A-Za-z0-9]+=)/).map(cookieString => {
export const parseCookies = (cookiesHeader: string): {cookies: Cookie[]} => {
if (!cookiesHeader) return {cookies: []};
const cookies = cookiesHeader.split(/,(?=\s[A-Za-z0-9]+=)/).map(cookieString => {
const [nameValuePair, ...attributePairs] = cookieString.split('; ').map(part => part.trim());
const [name, value] = nameValuePair.split('=');
const attributes: Record<string, string> = {};
@@ -152,9 +152,10 @@ export const parseCookies = (cookiesHeader: string): Cookie[] => {
});
return { name, value, attributes };
});
return { cookies }
}
export const parseRobotsTxt = (content: string): RowProps[] => {
export const parseRobotsTxt = (content: string): { robots: RowProps[] } => {
const lines = content.split('\n');
const rules: RowProps[] = [];
@@ -182,7 +183,7 @@ export const parseRobotsTxt = (content: string): RowProps[] => {
}
});
return rules;
return { robots: rules };
}
export const applyWhoIsResults = (response: any) => {