Skip to content

Commit fe36012

Browse files
committed
fix: prevent double-prefix when index ns overlaps manifest name
When the xpkg.lua descriptor has namespace='mcpplibs' but the upstream tarball's mcpp.toml still uses the old full name 'mcpplibs.tinyhttps' (no namespace field), the lua-ns propagation was injecting 'mcpplibs' into an already-prefixed name, producing 'mcpplibs.mcpplibs.tinyhttps'. Guard: skip injection when the manifest name already starts with the lua namespace.
1 parent 231b870 commit fe36012

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/cli.cppm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,8 +1186,16 @@ prepare_build(bool print_fingerprint,
11861186
// Propagate lua-level namespace into the loaded manifest when
11871187
// the manifest itself doesn't carry one (Form A descriptors
11881188
// whose upstream mcpp.toml predates the namespace field).
1189+
// Guard: if the manifest's name already starts with luaNs+"."
1190+
// (e.g. name="mcpplibs.tinyhttps" with luaNs="mcpplibs"),
1191+
// the namespace is already embedded in the name — don't inject
1192+
// it again or the scanner will produce a double-prefixed
1193+
// qualified name like "mcpplibs.mcpplibs.tinyhttps".
11891194
if (manifest->package.namespace_.empty() && !luaNs.empty()) {
1190-
manifest->package.namespace_ = luaNs;
1195+
auto prefix = luaNs + ".";
1196+
if (!manifest->package.name.starts_with(prefix)) {
1197+
manifest->package.namespace_ = luaNs;
1198+
}
11911199
}
11921200

11931201
return std::pair{effRoot, std::move(*manifest)};
@@ -3290,7 +3298,7 @@ int run(int argc, char** argv) {
32903298
std::string_view a = argv[1];
32913299
if (a == "--help" || a == "-h") { print_usage(); return 0; }
32923300
if (a == "--version" || a == "-V") {
3293-
std::println("mcpp {}", mcpp::toolchain::MCPP_VERSION);
3301+
std::println("mcpp {} - ", mcpp::toolchain::MCPP_VERSION);
32943302
return 0;
32953303
}
32963304
}

0 commit comments

Comments
 (0)