mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 03:27:52 +00:00
chore: Refactors help center article url helper (#8269)
This commit is contained in:
committed by
GitHub
parent
ebe9daea00
commit
23ea829510
@@ -64,3 +64,35 @@ export const isValidURL = value => {
|
||||
/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm;
|
||||
return URL_REGEX.test(value);
|
||||
};
|
||||
|
||||
export const getArticleSearchURL = ({
|
||||
host,
|
||||
portalSlug,
|
||||
pageNumber,
|
||||
locale,
|
||||
status,
|
||||
authorId,
|
||||
categorySlug,
|
||||
sort,
|
||||
query,
|
||||
}) => {
|
||||
const queryParams = new URLSearchParams({});
|
||||
|
||||
const params = {
|
||||
page: pageNumber,
|
||||
locale,
|
||||
status,
|
||||
author_id: authorId,
|
||||
category_slug: categorySlug,
|
||||
sort,
|
||||
query,
|
||||
};
|
||||
|
||||
Object.entries(params).forEach(([key, value]) => {
|
||||
if (value !== null && value !== undefined) {
|
||||
queryParams.set(key, value);
|
||||
}
|
||||
});
|
||||
|
||||
return `${host}/${portalSlug}/articles?${queryParams.toString()}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user