diff --git a/lib/provider/cli.js b/lib/provider/cli.js index ff27eb5..02050fc 100644 --- a/lib/provider/cli.js +++ b/lib/provider/cli.js @@ -8,6 +8,7 @@ const { exec } = require('node:child_process'); const { isValidNamespace, isValidName, isValidVersion, isValidProtocol } = require('../cli-helpers'); const { genShaSums, sign, exportPublicKey, publish } = require('./provider'); +const { escapeRegExp } = require('../util'); const registryAddr = process.env.CITIZEN_ADDR || 'http://127.0.0.1:3000'; @@ -78,7 +79,7 @@ module.exports = async (namespace, type, version, protocols, cmd) => { spinner.start(); const files = await readdir(targetDir); - const providerRegex = new RegExp(`${fileNamePrefix}_(?.*)_(?.*).zip`); + const providerRegex = new RegExp(`${escapeRegExp(fileNamePrefix)}_(?.*)_(?.*)\\.zip`); const providerArchives = files.filter((f) => f.match(providerRegex)); if (providerArchives.length === 0) { diff --git a/lib/util.js b/lib/util.js index c7a7dda..aff3ead 100644 --- a/lib/util.js +++ b/lib/util.js @@ -198,9 +198,14 @@ const normalizeSqlitePath = () => { } }; +const escapeRegExp = (str) => { + return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +}; + module.exports = { makeUrl, parseHcl, extractShasum, normalizeSqlitePath, + escapeRegExp, };