Skip to content

Commit

Permalink
[Loc]MWPW-164350 - Fragments are getting added multiple times in the …
Browse files Browse the repository at this point in the history
…Enter urls (#3393)
  • Loading branch information
nkthakur48 authored Dec 18, 2024
2 parents 83322ce + fa79ccf commit 5129a77
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libs/blocks/locui-create/input-urls/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { findDeepFragments } from '../../locui/actions/index.js';
import { urls as locuiUrls } from '../../locui/utils/state.js';
import { validateUrlsFormat } from '../../locui/loc/index.js';
import { origin } from '../../locui/utils/franklin.js';
import { PROJECT_TYPES } from '../utils/constant.js';
Expand Down Expand Up @@ -66,6 +67,8 @@ export function checkForErrors(errors) {
}

export async function findFragments(urls) {
// Using locui state urls as it is internally used in finding fragments and check duplicates
locuiUrls.value = [...urls];
const fragmentUrls = urls.map((url) => findDeepFragments(url.pathname));
const pageFragments = await Promise.all(fragmentUrls);
const fragmentsByPathname = pageFragments.reduce((acc, fragments, index) => {
Expand All @@ -82,9 +85,11 @@ export async function findFragments(urls) {
}
return acc;
}, {});
locuiUrls.value = [];
const foundFragments = Object.values(fragmentsByPathname);
return validateUrlsFormat(foundFragments, true);
}

export function getInitialName(type) {
const prefix = type === PROJECT_TYPES.rollout ? 'rollout' : 'translate';
let date = new Date().toISOString();
Expand Down

0 comments on commit 5129a77

Please sign in to comment.