Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use encodeURIComponent instead of encodeURI #1293

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions frontend/src/components/pages/details/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ export const generateChildrenDetailsUrl = (

export const generateTouristicContentUrl = (id: number | string, title: string): string => {
const titleWithNoSpace = convertStringForSitemap(title);
return `${routes.TOURISTIC_CONTENT}/${id}-${encodeURI(titleWithNoSpace)}`;
return `${routes.TOURISTIC_CONTENT}/${id}-${encodeURIComponent(titleWithNoSpace)}`;
};

export const generateOutdoorSiteUrl = (id: number | string, title: string): string => {
const titleWithNoSpace = convertStringForSitemap(title);
return `${routes.OUTDOOR_SITE}/${id}-${encodeURI(titleWithNoSpace)}`;
return `${routes.OUTDOOR_SITE}/${id}-${encodeURIComponent(titleWithNoSpace)}`;
};

export const generateOutdoorCourseUrl = (id: number | string, title: string): string => {
const titleWithNoSpace = convertStringForSitemap(title);
return `${routes.OUTDOOR_COURSE}/${id}-${encodeURI(titleWithNoSpace)}`;
return `${routes.OUTDOOR_COURSE}/${id}-${encodeURIComponent(titleWithNoSpace)}`;
};

export const generateTouristicEventUrl = (id: number | string, title: string): string => {
const titleWithNoSpace = convertStringForSitemap(title);
return `${routes.TOURISTIC_EVENT}/${id}-${encodeURI(titleWithNoSpace)}`;
return `${routes.TOURISTIC_EVENT}/${id}-${encodeURIComponent(titleWithNoSpace)}`;
};

export const generateDetailsUrlFromType = (
Expand All @@ -53,7 +53,7 @@ export const generateDetailsUrlFromType = (
): string => {
const searchParams = params ? `?${new URLSearchParams(params).toString()}` : '';
const titleWithNoSpace = convertStringForSitemap(title);
return `${routes[type]}/${id}-${encodeURI(titleWithNoSpace)}${searchParams}`;
return `${routes[type]}/${id}-${encodeURIComponent(titleWithNoSpace)}${searchParams}`;
};

export const templatesVariablesAreDefinedAndUsed = ({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/pages/search/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const generateResultDetailsUrl = (
parentId?: number,
): string => {
const titleWithNoSpace = convertStringForSitemap(title);
const detailsPageUrl = `${route}/${encodeURIComponent(id)}-${encodeURI(titleWithNoSpace)}${
const detailsPageUrl = `${route}/${encodeURIComponent(id)}-${encodeURIComponent(titleWithNoSpace)}${
parentId ? `?parentId=${parentId}` : ''
}`;

Expand Down
8 changes: 4 additions & 4 deletions frontend/src/pages/sitemap.xml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const getApiContentForLanguage = async (language: string): Promise<string> => {
const touristicContentUrls = touristicContents
.map(({ id, name }) =>
name && id
? `<url><loc>${baseUrl}/service/${id}-${encodeURI(
? `<url><loc>${baseUrl}/service/${id}-${encodeURIComponent(
convertStringForSitemap(name),
)}</loc></url>`
: '',
Expand All @@ -93,7 +93,7 @@ const getApiContentForLanguage = async (language: string): Promise<string> => {
const outdoorSitesUrls = outdoorSites
.map(({ id, name }) =>
name && id
? `<url><loc>${baseUrl}/outdoor-site/${id}-${encodeURI(
? `<url><loc>${baseUrl}/outdoor-site/${id}-${encodeURIComponent(
convertStringForSitemap(name),
)}</loc></url>`
: '',
Expand All @@ -106,7 +106,7 @@ const getApiContentForLanguage = async (language: string): Promise<string> => {
const outdoorCoursesUrls = outdoorCourses
.map(({ id, name }) =>
name && id
? `<url><loc>${baseUrl}/outdoor-course/${id}-${encodeURI(
? `<url><loc>${baseUrl}/outdoor-course/${id}-${encodeURIComponent(
convertStringForSitemap(name),
)}</loc></url>`
: '',
Expand All @@ -119,7 +119,7 @@ const getApiContentForLanguage = async (language: string): Promise<string> => {
external_url !== null && external_url.length > 0
? `<url><loc>${external_url}</loc></url>`
: title && id
? `<url><loc>${baseUrl}/information/${id}-${encodeURI(
? `<url><loc>${baseUrl}/information/${id}-${encodeURIComponent(
convertStringForSitemap(title),
)}</loc></url>`
: '',
Expand Down
Loading