DIYgod / RSSHub

🧡 Everything is RSSible
https://docs.rsshub.app
MIT License
34.08k stars 7.6k forks source link

Epic Free Games 路由异常 #13548

Closed People-11 closed 1 year ago

People-11 commented 1 year ago

路由地址

/epicgames/freegames/:locale?/:country?

完整路由地址

/epicgames/freegames/zh_CN

相关文档

https://docs.rsshub.app/routes/game#epic-games-store

预期是什么?

在 index.js 的第 44 行

const linkSlug = item.catalogNs.mappings.length > 0 ? item.catalogNs.mappings[0].pageSlug : item.offerMappings.length > 0 ? item.offerMappings[0].pageSlug : item.productSlug ? item.productSlug : item.urlSlug;

如果 item.catalogNs.mappings 数组的长度大于 0,就取 item.catalogNs.mappings[0].pageSlug 的值作为 linkSlug。

如果上述条件不满足,且 item.offerMappings 数组的长度大于 0,就取 item.offerMappings[0].pageSlug 的值作为 linkSlug。

如果前两个条件都不满足,且 item.productSlug 存在(不为 falsy 值,比如 null、undefined、false 等),就取 item.productSlug 的值作为 linkSlug。

如果前三个条件都不满足,就取 item.urlSlug 的值作为 linkSlug。

实际发生了什么?

在 index.js 的第 44 行

const linkSlug = item.catalogNs.mappings.length > 0 ? item.catalogNs.mappings[0].pageSlug : item.offerMappings.length > 0 ? item.offerMappings[0].pageSlug : item.productSlug ? item.productSlug : item.urlSlug;

判断 item.catalogNs.mappings 和 item.offerMappings 的长度大于 0 (即有内容存在) 时,使用 item.catalogNs.mappings 或 item.offerMappings

但是,当这两个值为 null 或 undefined 时,实际上无法读取长度,则会报 Cannot read properties of null (reading 'length') 错误

实际上,这种情况已经发生 (如下图)

Snipaste_2023-10-19_06-42-47 Snipaste_2023-10-19_06-58-23

部署

RSSHub 演示 (https://rsshub.app)

部署相关信息

Vercel

额外信息

Cannot read properties of null (reading 'length')

这不是重复的 issue

github-actions[bot] commented 1 year ago
Searching for maintainers:

To maintainers: if you are not willing to be disturbed, list your username in scripts/workflow/test-issue/call-maintainer.js. In this way, your username will be wrapped in an inline code block when tagged so you will not be notified.

如果所有路由都无法匹配,issue 将会被自动关闭。如果 issue 和路由无关,请使用 NOROUTE 关键词,或者留下评论。我们会重新审核。 If all routes can not be found, the issue will be closed automatically. Please use NOROUTE for a route-irrelevant issue or leave a comment if it is a mistake.

github-actions[bot] commented 1 year ago
Searching for maintainers:

To maintainers: if you are not willing to be disturbed, list your username in scripts/workflow/test-issue/call-maintainer.js. In this way, your username will be wrapped in an inline code block when tagged so you will not be notified.

如果所有路由都无法匹配,issue 将会被自动关闭。如果 issue 和路由无关,请使用 NOROUTE 关键词,或者留下评论。我们会重新审核。 If all routes can not be found, the issue will be closed automatically. Please use NOROUTE for a route-irrelevant issue or leave a comment if it is a mistake.

github-actions[bot] commented 1 year ago
Searching for maintainers:

To maintainers: if you are not willing to be disturbed, list your username in scripts/workflow/test-issue/call-maintainer.js. In this way, your username will be wrapped in an inline code block when tagged so you will not be notified.

如果所有路由都无法匹配,issue 将会被自动关闭。如果 issue 和路由无关,请使用 NOROUTE 关键词,或者留下评论。我们会重新审核。 If all routes can not be found, the issue will be closed automatically. Please use NOROUTE for a route-irrelevant issue or leave a comment if it is a mistake.