The original code directly accessed nested properties on
`post.hero_image`, which is not guaranteed to exist.
This cause a TypeError when the image object was nil.
This commit introduces safe access by:
- Prioritizing `hero_image` but falling back to `og_image`
- Only rendering the banner if a valid image URL was resolved
* Initial plan
* Replace @tonyrl/rand-user-agent with header-generator and add sec-ch-* headers
Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>
* Extract unwanted UA validation into standalone isValidUserAgent function
Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>
* Add headerGeneratorPreset option to got and ofetch utilities
* Replace randUserAgent usage in lib/routes with headerGeneratorPreset option
Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>
* chore: pin header-generator to exact match
* fix: replace randUserAgent with a static user agent string in config
* Remove deprecated _randUserAgent function and related tests
Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>
* refactor: rename to header-generator
* Changes before error encountered
Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>
* fix: update generateHeaders parameter type to Partial<HeaderGeneratorOptions>
* fix: add ios preset
* fix: rename headerGeneratorPreset to headerGeneratorOptions
* feat: add MODERN_IOS preset and update header-generator patch hash
* fix: use ios preset
* fix: update FetchOptions to include headerGeneratorOptions type
* refactor: simplify header generation and update header inclusion list
* fix: remove header-generator patch
* refactor: update user-agent handling in requests and tests
* test: remove redundant headerGeneratorOptions test and add new ofetch header preset test
* test: add custom user-agent test for ofetch
* test: update user-agent expectation in ofetch headers test
* Update lib/utils/ofetch.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* refactor: replace hardcoded headers with generatedHeaders in fetch and get request handlers
* refactor: rename test suite from rand-user-agent to header-generator and remove unused dependency
* Update lib/utils/header-generator.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* feat(route): add netflix
* feat: add research
* fix: remove migrated entries
* fix: clean up
* fix: remove optional chaining for embedLink and title in render function
* fix: remove optional chaining for embedLink
* fix: image url
* fix: remove empty target field in radar configuration
* feat(route): add ctinews
* fix(handler): adjust publication date timezone for video items
* fix(handler): correct timezone function import for publication date
* feature(route/aiaa): new router added
* feature(router/aiaa): rebuild rss from official
* feature(route/aiaa): new to old pudate list with preprint and current issue
* feature(route/aiaa): fix example
* feat(route/aiaa): fix path
* feat(route/aiaa): fix path
* feat(route/aiaa): reuse DataItem and other optimization
* delete empty file
* fix namespace
* fix(route/bilibili): only get subtitle for jsonfeed
* Update lib/middleware/cache.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* Update lib/middleware/cache.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
---------
* fix(route/github): Fix url of PR event not links to HTML page
* fix(route/github): Fix repo info be replaced in push event
* style: auto format
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* feat(route): add eastmoney gerenzhongxin cfh
* feat(route): add eastmoney gerenzhongxin guba trpl
* feat(route): add eastmoney gerenzhongxin gather
* Update lib/routes/eastmoney/gerenzhongxin/cfh.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* Update lib/routes/eastmoney/gerenzhongxin/cfh.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* Update lib/routes/eastmoney/gerenzhongxin/guba.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* Update lib/routes/eastmoney/gerenzhongxin/cfh.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* Update lib/routes/eastmoney/gerenzhongxin/trpl.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* Update lib/routes/eastmoney/gerenzhongxin/guba.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* Update lib/routes/eastmoney/gerenzhongxin/trpl.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* Update lib/routes/eastmoney/gerenzhongxin/gather.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* Update lib/routes/eastmoney/gerenzhongxin/guba.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* Update lib/routes/eastmoney/gerenzhongxin/trpl.ts
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
* Update use post_title instead.
* Update use blockquote instead.
* restore the abbreviated content as title. For the website is like twitter, there are only contents, no post_title.
* use blockquote to properly and semantically format the post and reply content
* Some of the posts do have a valid post_title. Now the post title has a precedence, if it is not valid, then use the abbreviated content
* fix deepscan result for INSUFFICIENT_NULL_CHECK
* fix deepscan result
---------
* fix(route/yjsy): use puppeteer to bypass WAF
* fix: chage waiting-util to get fully loaded page
* fix: remove 'stylesheet' from excludeResourceTypes in yjsy route
* chore: provide default title for notifications in yjsy route
* fix: add HTTP headers for Puppeteer page requests in yjsy route
* fix: replace global ua in config with a static value
* fix: change waitUntil from 'networkidle0' to 'networkidle2'
* fix: set ua with setUserAgent
* fix: ensure user agent is set after HTTP headers in Puppeteer page requests
* fix: add limit parameter to handler for controlling result set size
* fix: update resource type handling in request interception
- use default maxAge managed by env
* Fix content extraction and html output
- Content extraction was breaking in case it included a templating
instruction
- the html output was non-compliant html by having nested <ul>...</ul>
not belonging to a <li>...</li> element.
* refactor processListsAndLines in smaller functions
* fix date consistency
- title was using a date reconstructed from UTC time which led to
discrepancy between the content date and the title
- pubDate was based off the gmt time at which the process was
run. Instead, if the last possible entry time (23.59.59 gmt-12) is
passed, we use that, if not we use current time. This should reflect
more or less a form of 'publish' date status from this portal.
* ensure empty-ish page doesn't lead to entry creation
* fix(route/sciencedirect): fix abstract will not show when highlights appear
now both abstract and highlights will show. only abstract will be shown when there is no highlights for the paper
* Update current-issue.ts
* fix(route/sciencedirect): fix vary length of abstract array