-
-
Save davenotik/d970f5a05a586f4b5cf8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rewrite URLs from relative to absolute so URLs | |
// like /item/whatever properly load the app. | |
// See http://goo.gl/Y5ERIY | |
if (request.uri.path.contains('packages/')) { | |
var path = request.uri.path.replaceFirst(new RegExp('^.*?packages/'), ''); | |
var file = new File(config['server']['directory'] + '/packages/$path'); | |
virtualDirectory.serveFile(file, request); | |
} else if (request.uri.path.contains('static/')) { | |
var path = request.uri.path.replaceFirst(new RegExp('^.*?static/'), ''); | |
var file = new File(config['server']['directory'] + '/static/$path'); | |
virtualDirectory.serveFile(file, request); | |
// The following will handle either index.html or | |
// post-build assets like index.html_bootstrap.dart.js etc. | |
} else if (request.uri.path.contains('index.html')) { | |
var path = request.uri.path.replaceFirst(new RegExp('^.*?index.html'), ''); | |
var file = new File(config['server']['directory'] + '/index.html$path'); | |
virtualDirectory.serveFile(file, request); | |
} else if (request.uri.path.contains('index.dart')) { | |
var path = request.uri.path.replaceFirst(new RegExp('^.*?index.dart'), ''); | |
var file = new File(config['server']['directory'] + '/index.dart$path'); | |
virtualDirectory.serveFile(file, request); | |
// End of ugly relative/absolute handling. | |
} else { | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment