Eyeglass blows up parsing component URIs that start with a forward-slash
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 738
- Forks
- 48
- PR merge metrics
- No merged PRs in 30d
Description
In my case I have a utility called pancake generating root relative sass. Once parsed by eyeglass, this errors out. The offending code looks like:
```
var match = /^((?:@[^\/]+\/[^\/]+)|(?:[^\/]+))\/?(.*)/.exec(uri);
var moduleName = match && match[1];
var relativePath = match && match[2];
var mod = eyeglass.modules.access(moduleName, isRealFile ? prev : root);
// for back-compat with previous suggestion @see
// https://github.com/sass-eyeglass/eyeglass/issues/131#issuecomment-210728946
// if the module was not found and the name starts with `@`...
if (!mod && moduleName[0] === "@") {
```
In this code moduleName is null.
And the error it produces looks like:
```
/vagrant/node_modules/sass-versioning/dist/_index.scss
[16:14:31] The following tasks did not complete: default, styles:production, production
[16:14:31] Did you forget to signal async completion?
/vagrant/node_modules/eyeglass/lib/importers/ModuleImporter.js:104
if (!mod && moduleName[0] === "@") {
^
TypeError: Cannot read property '0' of null
at Object. (/vagrant/node_modules/eyeglass/lib/importers/ModuleImporter.js:104:27)
at Object. (/vagrant/node_modules/eyeglass/lib/importers/ImportUtilities.js:24:14)
at options.importer (/vagrant/node_modules/node-sass/lib/index.js:336:31)
^[[A^C
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in eyeglass/lib/importers/ModuleImporter.js at the reported line 104, then trace how the URI regex handles a leading slash and produces a null moduleName. Reproduce the importer failure with a root-relative component URI; done means that URI no longer triggers the null-property TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, sass
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100