mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Fix error on dash in instance name
Fix stripPaths logic breaking when the instance name contains RegExp meta characters due to a lack of escaping.
This commit is contained in:
1 parent
4c9b91ab57
commit
31c0925354
2 files changed
+11
-1
No files matched your search
@@ -554,7 +554,7 @@ class FactorioServer extends events.EventEmitter {
|
|||||||
this._stripRegExp = new RegExp(
|
this._stripRegExp = new RegExp(
|
||||||
`(${escapeRegExp(this.writePath("temp", "currently-playing", path.sep))})|` +
|
`(${escapeRegExp(this.writePath("temp", "currently-playing", path.sep))})|` +
|
||||||
`(${escapeRegExp(this.writePath(path.sep))})|` +
|
`(${escapeRegExp(this.writePath(path.sep))})|` +
|
||||||
`(\\.\\.\\.[${chars}]*?currently-playing\\${path.sep})`,
|
`(\\.\\.\\.[${escapeRegExp(chars)}]*?currently-playing\\${path.sep})`,
|
||||||
"g"
|
"g"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,6 +170,16 @@ describe("lib/factorio/server", function() {
|
|||||||
let writePath = path.join("temp", "test", "server");
|
let writePath = path.join("temp", "test", "server");
|
||||||
let server = new libFactorio.FactorioServer(path.join("test", "file", "factorio"), writePath, {});
|
let server = new libFactorio.FactorioServer(path.join("test", "file", "factorio"), writePath, {});
|
||||||
|
|
||||||
|
describe("constructor()", function() {
|
||||||
|
it("should handle dashes in write path with strapPaths enabled", function() {
|
||||||
|
new libFactorio.FactorioServer(
|
||||||
|
path.join("test", "file", "factorio"),
|
||||||
|
path.join("temp", "test", "server-1"),
|
||||||
|
{ stripPaths: true }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe(".init()", function() {
|
describe(".init()", function() {
|
||||||
it("should not throw on first call", async function() {
|
it("should not throw on first call", async function() {
|
||||||
await server.init();
|
await server.init();
|
||||||
|
|||||||
Reference in new issue
Block a user