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

Store encoding metadata #100

Open
josephmturner opened this issue Aug 23, 2024 · 1 comment
Open

Store encoding metadata #100

josephmturner opened this issue Aug 23, 2024 · 1 comment

Comments

@josephmturner
Copy link
Contributor

Currently, hypercore-fetch assumes that all text files are UTF-8 when returning a Content-Type header:

function getMimeType (path) {
  let mimeType = mime.getType(path) || 'text/plain; charset=utf-8'
  if (mimeType.startsWith('text/')) mimeType = `${mimeType}; charset=utf-8`
  return mimeType
}

In order to return the actual coding system for a file, we'd need to know how the file was encoded when it was written to the hyperdrive.

IIUC, the standard way to specify a file's encoding in a PUT request is in the Content-Type header, e.g., Content-Type: text/plain; charset=ISO-8859-1.

Once hypercore-fetch receives the file and its coding system, where should the encoding metadata be stored?

We could put it alongside the mtime metadata in entry.value.metadata.encoding. WDYT?

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

No branches or pull requests

1 participant