-
-
Notifications
You must be signed in to change notification settings - Fork 5
Implemented support for caseFold parameter on Archives File Systems
#17
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
base: main
Are you sure you want to change the base?
Conversation
james-pre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, I've gotten started with some suggestions to improve the code style and such. Thanks for contributing!
Co-authored-by: James Prevett <jp@jamespre.dev>
Co-authored-by: James Prevett <jp@jamespre.dev>
|
Also it would be nice to have a new test (or multiple new tests) to make this works correctly. |
james-pre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far. I have some very minor feedback but I think it is almost ready to merge.
| for (const part of path.split('/').slice(1)) { | ||
| if (!dir.isDirectory()) return; | ||
| dir = dir.directory.get(part); | ||
| const directory: Directory = dir.directory; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const directory: Directory = dir.directory; | |
| const { directory } = dir; |
| if (!next && this.options.caseFold) { | ||
| const foldedPart = this._caseFold(part); | ||
| for (const [name, record] of directory) { | ||
| if (this._caseFold(name) === foldedPart) { | ||
| next = record; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| dir = next; | ||
| if (!dir) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of difficult to read... if there is a way to make it more readable & reduce indentation that would be great— perhaps using a gaurd clause?
| private _caseFold(original: string): string { | ||
| if (!this.options.caseFold) { | ||
| return original; | ||
| } | ||
|
|
||
| return this.options.caseFold === 'upper' ? original.toUpperCase() : original.toLowerCase(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicated with ZipFS as well. To reduce duplcation, I'm thinking:
- Make
optionspublicbut add@internal - Change case fold to be
@internal, and take the FS:_caseFold(fs: FileSystem, path: string) => string - Both FSes use the shared case fold function
Implemented both ISO and ZIP and added Unit Tests