Skip to content

Server crashes when projectRoot contains a dot #30

Open
@Periclod

Description

@Periclod

More specifically the Server crashes when:

  • a manifest config exists in a path that contains a dot
  • The file doesn't end with either mjs or cjs.
  • The folder with the dot is in a write-protected path

The cause seems to be this regex https://github.com/Matsuuu/custom-elements-language-server/blob/main/lib/custom-elements-languageserver-core/src/cem/analyzer.ts#L145 that greedy-matches the .* to everything after the first dot

        const tempManifestFilePath = closestConfigPath.replace(new RegExp(/\..*js$/), ".mjs");

If the project is located in /Users/firstname.lastname/path/to/project the regex will replace the config name with /Users/firstname.mjs.

This also replaces the config part of the manifest filename so I'm not sure if the greedyness is intended

Also the if condition right before is broken and always returns true

    if (!closestConfigPath.endsWith("mjs") || !closestConfigPath.endsWith("cjs")) {

Reproduction:

  • check out this repo in a path with a dot in it
  • cd into the usage-testing-project
  • try to goto-definition on a custom element in the index.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions