Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] String.prototype.replaceAll 存在 bug #60

Closed
zheng7fu2 opened this issue Oct 9, 2022 · 6 comments
Closed

[BUG] String.prototype.replaceAll 存在 bug #60

zheng7fu2 opened this issue Oct 9, 2022 · 6 comments
Milestone

Comments

@zheng7fu2
Copy link

[email protected] app
node backend/src/index.js

/root/melody/backend/src/service/media_fetcher/../../../bin/media-get [ '-h' ]
ℹ [media-get] Version: 0.2.8 11:50:20
ℹ [tmp path] use /tmp/melody-tmp-songs 11:50:20
/root/melody/backend/src/index.js:3
return this.replace(new RegExp(f, 'g'), r);
^

SyntaxError: Invalid regular expression: /*/: Nothing to repeat
at new RegExp ()
at String.replaceAll (/root/melody/backend/src/index.js:3:23)
at node:internal/assert/snapshot:28:61
at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/loaders:331:7)
at nativeModuleRequire (node:internal/bootstrap/loaders:362:14)
at node:assert:1055:18
at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/loaders:331:7)
at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/loaders:269:10)
at loadBuiltinModule (node:internal/modules/cjs/helpers:50:9)
at Module._load (node:internal/modules/cjs/loader:847:15)

Node.js v18.10.0

@foamzou
Copy link
Owner

foamzou commented Oct 18, 2022

在 mac 和 windows 的 18.10 均无法复现。请问有什么我遗漏的复现步骤吗?
@zheng7fu2 @atomicink

@atomicink
Copy link

我用的mac mini m1,手动下载的media-get并给了权限,测试可以单独运行
没有其他步骤

@JuZi233
Copy link

JuZi233 commented Nov 14, 2022

我也是这个错,莫名其妙的

@foamzou
Copy link
Owner

foamzou commented Nov 14, 2022

可以先手动删除 backend/src/index.js 这几行.

// NeteaseCloudMusicApi 有不兼容的代码。晚点提 PR 改下,这里先 hack
String.prototype.replaceAll = function (f, r) {
  return this.replace(new RegExp(f, 'g'), r);
};

然后升级下 NeteaseCloudMusicApi

cd backend
npm update NeteaseCloudMusicApi

最近比较懒,没有写代码。 @atomicink @JuZi233

@foamzou foamzou closed this as completed Jan 16, 2025
@foamzou foamzou changed the title [BUG] 源码安装后启动失败。Debian testing [BUG] String.prototype.replaceAll 存在 bug Jan 20, 2025
@foamzou foamzou reopened this Jan 20, 2025
@foamzou
Copy link
Owner

foamzou commented Jan 20, 2025

node 16 之后已经支持 replaceAll,可以移除实现不严谨的 String.prototype.replaceAll
文件位置: backend/src/index.js 前几行

@foamzou foamzou added this to the v1.1.1 milestone Jan 20, 2025
@foamzou
Copy link
Owner

foamzou commented Jan 21, 2025

fixed

@foamzou foamzou closed this as completed Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants