| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of vmservice; | 5 part of vmservice; |
| 6 | 6 |
| 7 String detectMimeType(String name) { | 7 String detectMimeType(String name) { |
| 8 var extensionStart = name.lastIndexOf('.'); | 8 var extension = new Path(name).extension; |
| 9 var extension = name.substring(extensionStart+1); | |
| 10 switch (extension) { | 9 switch (extension) { |
| 11 case 'html': | 10 case 'html': |
| 12 return 'text/html; charset=UTF-8'; | 11 return 'text/html; charset=UTF-8'; |
| 13 case 'dart': | 12 case 'dart': |
| 14 return 'application/dart; charset=UTF-8'; | 13 return 'application/dart; charset=UTF-8'; |
| 15 case 'js': | 14 case 'js': |
| 16 return 'application/javascript; charset=UTF-8'; | 15 return 'application/javascript; charset=UTF-8'; |
| 17 case 'css': | 16 case 'css': |
| 18 return 'text/css; charset=UTF-8'; | 17 return 'text/css; charset=UTF-8'; |
| 19 case 'gif': | 18 case 'gif': |
| (...skipping 14 matching lines...) Expand all Loading... |
| 34 final String name; | 33 final String name; |
| 35 final String mimeType; | 34 final String mimeType; |
| 36 final List<int> data; | 35 final List<int> data; |
| 37 Resource(this.name, this.mimeType, this.data); | 36 Resource(this.name, this.mimeType, this.data); |
| 38 static final Map<String, Resource> resources = new Map<String, Resource>(); | 37 static final Map<String, Resource> resources = new Map<String, Resource>(); |
| 39 } | 38 } |
| 40 | 39 |
| 41 | 40 |
| 42 void _addResource(String name, List<int> data) { | 41 void _addResource(String name, List<int> data) { |
| 43 var mimeType = detectMimeType(name); | 42 var mimeType = detectMimeType(name); |
| 44 Resource resource = new Resource(name, mimeType, data); | 43 Resource resource = new Resource(name, detectMimeType(name), data); |
| 45 Resource.resources[name] = resource; | 44 Resource.resources[name] = resource; |
| 46 } | 45 } |
| OLD | NEW |