mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-15 23:05:23 -05:00
feat: Optionally include URL when importing via HTML/JSON (#6709)
This commit is contained in:
@@ -510,6 +510,7 @@ export interface ScrapeRecipeBase {
|
||||
export interface ScrapeRecipeData {
|
||||
includeTags?: boolean;
|
||||
data: string;
|
||||
url?: string | null;
|
||||
}
|
||||
export interface ScrapeRecipeTest {
|
||||
url: string;
|
||||
|
||||
@@ -146,8 +146,8 @@ export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
|
||||
return await this.requests.post<Recipe | null>(routes.recipesTestScrapeUrl, { url, useOpenAI });
|
||||
}
|
||||
|
||||
async createOneByHtmlOrJson(data: string, includeTags: boolean) {
|
||||
return await this.requests.post<string>(routes.recipesCreateFromHtmlOrJson, { data, includeTags });
|
||||
async createOneByHtmlOrJson(data: string, includeTags: boolean, url: string | null = null) {
|
||||
return await this.requests.post<string>(routes.recipesCreateFromHtmlOrJson, { data, includeTags, url });
|
||||
}
|
||||
|
||||
async createOneByUrl(url: string, includeTags: boolean) {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export { scorePassword } from "./password";
|
||||
export { required, email, whitespace, url, minLength, maxLength } from "./inputs";
|
||||
export { required, email, whitespace, url, urlOptional, minLength, maxLength } from "./inputs";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const EMAIL_REGEX
|
||||
= /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@(([[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
|
||||
const URL_REGEX = /[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
||||
const URL_REGEX = /[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
||||
|
||||
export function required(v: string | undefined | null) {
|
||||
return !!v || "This Field is Required";
|
||||
@@ -19,6 +19,10 @@ export function url(v: string | undefined | null) {
|
||||
return (!!v && URL_REGEX.test(v)) || "Must Be A Valid URL";
|
||||
}
|
||||
|
||||
export function urlOptional(v: string | undefined | null) {
|
||||
return v ? url(v) : true;
|
||||
}
|
||||
|
||||
export function minLength(min: number) {
|
||||
return (v: string | undefined | null) => (!!v && v.length >= min) || `Must Be At Least ${min} Characters`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user