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

refactor: remove node's path to be able to use in client #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

daniil4udo
Copy link

No description provided.

Copy link
Member

@IamLizu IamLizu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting but there are edge cases for example with trailing slashes, it will return empty string. path does some sort of input validation and error handling like if you pass null or undefined in path.basename() it is handled.

Moreover, content disposition is fundamentally a server-side mechanism in the HTTP protocol (response headers) that instructs client (browser) on how to handle the content. It should be controlled by the server.

@IamLizu IamLizu self-assigned this Dec 31, 2024
@daniil4udo
Copy link
Author

Good call. I've refined it.

You're correct that Content-Disposition is defined as a server-side mechanism in the HTTP protocol, intended to instruct the client on handling the content. However, the protocol's client-side behavior opens up valid use cases for parsing this header on the client side. For example, extracting filenames from Content-Disposition is a common scenario when saving files downloaded via JavaScript in web applications.

Consider modern use cases where APIs serve files, and the client handles saving them. In such scenarios, the server provides Content-Disposition as metadata, but the client's role in interpreting it is equally critical for enabling seamless user experiences. While the server controls the header's value, parsing it client-side doesn't violate the protocol—it's merely leveraging the metadata for practical application.

In essence, both server and client share responsibilities in the broader mechanism, making client-side parsing a practical and legitimate extension of the standard's utility

@IamLizu IamLizu removed their assignment Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants