(
path: string,
options: GetDefaultFeedProps = {},
)
| 278 | export const defaultFeedConditions = [null, 'default', '/', '']; |
| 279 | |
| 280 | export const getFeedName = ( |
| 281 | path: string, |
| 282 | options: GetDefaultFeedProps = {}, |
| 283 | ): AllFeedPages => { |
| 284 | const feed = path?.replaceAll?.('/', '') || ''; |
| 285 | |
| 286 | if (defaultFeedConditions.some((condition) => condition === feed)) { |
| 287 | return getDefaultFeed(options); |
| 288 | } |
| 289 | if (feed.startsWith('search')) { |
| 290 | return SharedFeedPage.Search; |
| 291 | } |
| 292 | if (feed === '[userId]upvoted') { |
| 293 | return OtherFeedPage.UserUpvoted; |
| 294 | } |
| 295 | if (feed === '[userId]posts') { |
| 296 | return OtherFeedPage.UserPosts; |
| 297 | } |
| 298 | if (feed.startsWith('feeds')) { |
| 299 | const isMyFeedEdit = |
| 300 | ['edit'].some((item) => feed.endsWith(item)) && options.isMyFeed; |
| 301 | |
| 302 | return isMyFeedEdit ? SharedFeedPage.MyFeed : SharedFeedPage.Custom; |
| 303 | } |
| 304 | |
| 305 | const [page] = feed.split('?'); |
| 306 | |
| 307 | return page.replace(/^\/+/, '') as SharedFeedPage; |
| 308 | }; |
| 309 | |
| 310 | export type FeedAdTemplate = { |
| 311 | adStart: number; |
no test coverage detected