mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-05-11 12:33:32 -04:00
fix: make PWA share target functional on Android Chrome (#7468)
Co-authored-by: Zdenek <tvuj-email@example.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -198,15 +198,32 @@ const recipeUrl = computed({
|
||||
}
|
||||
},
|
||||
get() {
|
||||
return route.query.recipe_import_url as string | null;
|
||||
// Prefer the 'url' share field (recipe_import_url, populated by Chrome when
|
||||
// sharing a page URL). Fall back to the 'text' share field (recipe_import_text)
|
||||
// for apps that share URLs as plain text, but only when the text value is
|
||||
// actually a valid http/https URL — shared text can be arbitrary.
|
||||
const urlFromField = route.query.recipe_import_url as string | null;
|
||||
if (urlFromField) {
|
||||
return urlFromField;
|
||||
}
|
||||
const textFromField = route.query.recipe_import_text as string | null;
|
||||
if (textFromField) {
|
||||
try {
|
||||
const parsed = new URL(textFromField);
|
||||
if (parsed.protocol === "http:" || parsed.protocol === "https:") {
|
||||
return textFromField;
|
||||
}
|
||||
}
|
||||
catch { /* not a URL, ignore */ }
|
||||
}
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
if (recipeUrl.value && recipeUrl.value.includes("https")) {
|
||||
// Check if we have a query params for using keywords as tags or staying in edit mode.
|
||||
// We don't use these in the app anymore, but older automations such as Bookmarklet might still use them,
|
||||
// and they're easy enough to support.
|
||||
if (recipeUrl.value) {
|
||||
// Apply legacy query params for older automations such as the Bookmarklet.
|
||||
// These are no longer used by the app itself but are easy to keep supporting.
|
||||
const importKeywordsAsTagsParam = route.query.use_keywords;
|
||||
if (importKeywordsAsTagsParam === "1") {
|
||||
importKeywordsAsTags.value = true;
|
||||
@@ -223,8 +240,9 @@ onMounted(() => {
|
||||
stayInEditMode.value = false;
|
||||
}
|
||||
|
||||
createByUrl(recipeUrl.value, importKeywordsAsTags.value, false);
|
||||
return;
|
||||
// The URL is pre-filled via the recipeUrl computed property.
|
||||
// Do not auto-submit: the user should review the import options and
|
||||
// confirm by clicking the submit button.
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user