Skip to content

more flexible 'index' option for directory handler#10

Merged
kanongil merged 4 commits intohapijs:masterfrom
yortus:moreFlexibleIndexOption
Dec 30, 2014
Merged

more flexible 'index' option for directory handler#10
kanongil merged 4 commits intohapijs:masterfrom
yortus:moreFlexibleIndexOption

Conversation

@yortus
Copy link
Copy Markdown
Contributor

@yortus yortus commented Dec 3, 2014

This is a simple backwards-compatible extension to the directory handler, allowing the index option to be either a boolean (as before) or a string (new option).

This allows the index file to be configured to be something other than 'index.html', without breaking any previous behaviour.

There's also Joi validation to ensure nothing unsafe can be used.

EDIT: Added units tests.

@kanongil kanongil added feature New functionality or improvement release notes Major release documentation labels Dec 4, 2014
@kanongil
Copy link
Copy Markdown
Contributor

kanongil commented Dec 4, 2014

This sounds like a nice feature to include. While it won't do much for new deployments, it can simplify migration from other systems.

@hueniverse Would it make sense to allow array of index strings as well, similar to other web servers?

@yortus
Copy link
Copy Markdown
Contributor Author

yortus commented Dec 4, 2014

Why the regex?

@kanongil I was just being cautious, because I wasn't sure if allowing an arbitrary string could introduce any security holes.

@hueniverse
Copy link
Copy Markdown
Contributor

Array would be nice. As for security, the result path should go through the same checks as any other content.

@hueniverse hueniverse removed the release notes Major release documentation label Dec 4, 2014
@hueniverse
Copy link
Copy Markdown
Contributor

@kanongil Also, no need for the release notes label. That's for issues that are just notes. You can use the changelog system hapi uses for publishing changes if you want (we don't really do it outside hapi).

@yortus
Copy link
Copy Markdown
Contributor Author

yortus commented Dec 5, 2014

@kanongil @hueniverse Array support added, with units tests.

I also removed regex from validation, so any string, or array of strings, is permitted for the index option. Do other checks need to be added anywhere?

…Option

Conflicts:
	lib/directory.js
	test/directory.js
@kwo
Copy link
Copy Markdown

kwo commented Dec 18, 2014

+1 for this

kanongil added a commit to kanongil/inert that referenced this pull request Dec 30, 2014
more flexible 'index' option for directory handler
kanongil added a commit to kanongil/inert that referenced this pull request Dec 30, 2014
@kanongil kanongil added this to the 2.1.0 milestone Dec 30, 2014
@kanongil kanongil merged commit 2b8ce4e into hapijs:master Dec 30, 2014
@kanongil
Copy link
Copy Markdown
Contributor

@yortus I have published the 2.1.0 package with this as the only feature. Could you create a PR on hapi with the new version and a documentation update?

@yortus
Copy link
Copy Markdown
Contributor Author

yortus commented Jan 18, 2015

@kanongil Done, I think.

PR for hapi: hapijs/hapi#2354 (updated API.md)

PR for hapijs.com: outmoded/hapijs.com#126 (updated tutorial)

package.json in hapi has "inert": "2.x.x", so there's nothing else to change, unless I'm missing something?

@lock
Copy link
Copy Markdown

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature New functionality or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants