Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure _loaderHelpers registers actual filenames #24

Merged
merged 1 commit into from Jun 21, 2015

Conversation

@keithamus
Copy link
Contributor

keithamus commented Apr 12, 2015

Slicing a path by the last 3 characters works for two character extensions, e.g. '.js' or '.cs' but not for longer extensions ('.es6' for example).

Using Path.extname will extract the proper extension name from a path, enabling support for files with long extensions.

@jagoda

This comment has been minimized.

Copy link
Contributor

jagoda commented Apr 14, 2015

I don't believe that Path.parse() is available in Node 0.10.

@keithamus

This comment has been minimized.

Copy link
Contributor Author

keithamus commented Apr 14, 2015

@jagoda, you're totally right, my bad. I noticed this as I disappointedly watched travis fail. I've updated with code that works in .10, and also some tests to ensure the desired functionality actually works. (Also updated OP to reflect actual change)

@keithamus keithamus force-pushed the keithamus:patch-1 branch from 0e194f4 to 90edd16 Apr 14, 2015
var offset = path.slice(-1) === Path.sep ? 0 : 1;
var name = file.slice(path.length + offset, -3);
var name = Path.basename(file);
name = name.slice(0, -path.extname(name).length);

This comment has been minimized.

Copy link
@jagoda

jagoda Apr 14, 2015

Contributor

I don't think that this will work correctly for helpers that are in subdirectories. Any reason to not use the original approach but just replace -3 with -Path.extname(file).length?

Slicing a path by the last 3 characters works for two character
extensions, e.g. `'.js'` or `'.cs'` but not for longer extensions
(`'.es6'`, `'.javascript'`, `'.coffeescript'` for example).

Using `Path.extname` will extract the proper extension from a path,
which can then be used to determine the length of the extension proper,
and thereby allowing helpers with longer extension names.
@keithamus

This comment has been minimized.

Copy link
Contributor Author

keithamus commented Apr 15, 2015

@jagoda amended.

@keithamus keithamus force-pushed the keithamus:patch-1 branch from 90edd16 to 429116e Apr 15, 2015
@jagoda

This comment has been minimized.

Copy link
Contributor

jagoda commented Apr 15, 2015

Cool. Looks good to me.

@keithamus

This comment has been minimized.

Copy link
Contributor Author

keithamus commented Apr 15, 2015

@hueniverse I can has merge?

@jagoda

This comment has been minimized.

Copy link
Contributor

jagoda commented May 21, 2015

@hueniverse I am happy to merge this if given the commit bit.

@hueniverse hueniverse added the bug label Jun 21, 2015
@hueniverse hueniverse added this to the 2.0.1 milestone Jun 21, 2015
@hueniverse hueniverse self-assigned this Jun 21, 2015
hueniverse added a commit that referenced this pull request Jun 21, 2015
Ensure _loaderHelpers registers actual filenames
@hueniverse hueniverse merged commit 3e085c4 into hapijs:master Jun 21, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@keithamus keithamus deleted the keithamus:patch-1 branch Jun 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.