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

Example files.dart ContentTypes forFile returns null ContentType #81

Open
mkhan-akhan opened this issue Mar 15, 2014 · 2 comments
Open

Comments

@mkhan-akhan
Copy link

In the Example in files.dart, ContentTypes.forFile returns null because _extensions map is missing a dot in the keys. path.extension(file.path) returns the extensions with a dot prefixed. Hence 'css' : CSS should be '.css' : CSS.

@mkhan-akhan
Copy link
Author

It was causing my style.css to be loaded as 'text/plain' which resulted in none of the styles being applied.

@akserg
Copy link

akserg commented Jul 29, 2014

I have the same problem because Path.extension function

Gets the file extension of path: the portion of basename from the last . to the end (including the . itself).

Opposite of mkhan-akhan solution I offer left extension names "as is" but make changes in forFile method like that:

static ContentType forFile(File file) {
  String ext = path.extension(file.path);
  return _extensions[ext.length > 0 ? ext.substring(1) : ext];
}

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

2 participants