Join directory + relative entry path, normalize. * "packages/foo" + "src/index.ts" → "packages/foo/src/index" (stripped ext) */
| 165 | /* Join directory + relative entry path, normalize. |
| 166 | * "packages/foo" + "src/index.ts" → "packages/foo/src/index" (stripped ext) */ |
| 167 | static char *join_and_strip(const char *dir, const char *entry) { |
| 168 | if (!entry || entry[0] == '\0') { |
| 169 | return NULL; |
| 170 | } |
| 171 | /* Skip leading ./ from entry */ |
| 172 | if (entry[0] == '.' && entry[SKIP_ONE] == '/') { |
| 173 | entry += PAIR_LEN; |
| 174 | } |
| 175 | char buf[PKGMAP_PATH_BUF]; |
| 176 | if (dir[0] == '\0') { |
| 177 | snprintf(buf, sizeof(buf), "%s", entry); |
| 178 | } else { |
| 179 | snprintf(buf, sizeof(buf), "%s/%s", dir, entry); |
| 180 | } |
| 181 | return strip_extension(buf); |
| 182 | } |
| 183 | |
| 184 | /* Check if a string ends with a suffix. */ |
| 185 | static bool ends_with(const char *s, const char *suffix) { |
no test coverage detected