Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash committed Dec 9, 2024
1 parent b5e596a commit 7bd2da2
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions frontend/src/pages/drafts/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,34 @@ const joinPerformers = <T extends Performer>(
),
];

const parseUrls = (
urls: string[],
type: ValidSiteTypeEnum,
sites: Site[],
): [URL[], string[]] => {
const matches = [];
const remainder = [];

for (const url of urls) {
if (url == "") continue;

const matchedSite = sites.find((site) => {
if (!site.valid_types.includes(type) || !site.regex) return false;

return Boolean(url.match(site.regex));
});

if (matchedSite)
matches.push({
url: cleanURL(matchedSite.regex, url) ?? url,
site: { id: matchedSite.id, name: matchedSite.name },
});
else remainder.push(url);
}
return [matches, remainder];
};


const parseSceneUrls = (
urls: string[],
type: ValidSiteTypeEnum,
Expand Down Expand Up @@ -188,33 +216,6 @@ const parseAliases = (value: string | null | undefined) => {
return null;
};

const parseUrls = (
urls: string[],
type: ValidSiteTypeEnum,
sites: Site[],
): [URL[], string[]] => {
const matches = [];
const remainder = [];

for (const url of urls) {
if (url == "") continue;

const matchedSite = sites.find((site) => {
if (!site.valid_types.includes(type) || !site.regex) return false;

return Boolean(url.match(site.regex));
});

if (matchedSite)
matches.push({
url: cleanURL(matchedSite.regex, url) ?? url,
site: { id: matchedSite.id, name: matchedSite.name },
});
else remainder.push(url);
}
return [matches, remainder];
};

export const parsePerformerDraft = (
draft: PerformerDraft,
existingPerformer: PerformerFragment | undefined,
Expand Down

0 comments on commit 7bd2da2

Please sign in to comment.