(
path: string,
options: GetDefaultFeedProps = {},
)
| 245 | export const defaultFeedConditions = [null, 'default', '/', '']; |
| 246 | |
| 247 | export const getFeedName = ( |
| 248 | path: string, |
| 249 | options: GetDefaultFeedProps = {}, |
| 250 | ): AllFeedPages => { |
| 251 | const feed = path?.replaceAll?.('/', '') || ''; |
| 252 | |
| 253 | if (defaultFeedConditions.some((condition) => condition === feed)) { |
| 254 | return getDefaultFeed(options); |
| 255 | } |
| 256 | if (feed.startsWith('search')) { |
| 257 | return SharedFeedPage.Search; |
| 258 | } |
| 259 | if (feed === '[userId]upvoted') { |
| 260 | return OtherFeedPage.UserUpvoted; |
| 261 | } |
| 262 | if (feed === '[userId]posts') { |
| 263 | return OtherFeedPage.UserPosts; |
| 264 | } |
| 265 | if (feed.startsWith('feeds')) { |
| 266 | const isMyFeedEdit = |
| 267 | ['edit'].some((item) => feed.endsWith(item)) && options.isMyFeed; |
| 268 | |
| 269 | return isMyFeedEdit ? SharedFeedPage.MyFeed : SharedFeedPage.Custom; |
| 270 | } |
| 271 | |
| 272 | const [page] = feed.split('?'); |
| 273 | |
| 274 | return page.replace(/^\/+/, '') as SharedFeedPage; |
| 275 | }; |
| 276 | |
| 277 | export type FeedAdTemplate = { |
| 278 | adStart: number; |
no test coverage detected