In one webapp that I'm working with, I have deal with URLs like the one below:
http://localhost:8080/section/value.with.periods
This value.with.periods
is a URL param, like the ones that you declare on angular's routeProvider
:
angular.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/section/:param', {
templateUrl: 'url-to-template',
controller: 'ExampleCtrl',
resolve: {
...
}
});
}]);
The problem is that the server used, running under Grunt tasks, cannot handle URLs with periods in it:
Cannot GET /section/value.with.periods
I'm running Grunt with grunt-contrib-proxy
and connect-modrewrite
, and the livereload
task, which configures the connect-modrewrite
, is the one below:
livereload: {
options: {
open: 'http://localhost:<%= connect.options.port %>',
base: [
'.tmp',
'<%= config.app %>'
],
middleware: function(connect, options) {
if (!Array.isArray(options.base)) {
options.base = [options.base];
}
// Setup the proxy
var middlewares = [proxySnippet];
var modRewrite = require('connect-modrewrite');
middlewares.push(modRewrite(['^[^\\.]*$ /index.html [L]']));
// middlewares.push(modRewrite(['!\\.html|\\.js|\\.svg|\\.css|\\.png|\\.jpg\\.gif|\\swf$ /index.html [L]']));
// Serve static files.
options.base.forEach(function(base) {
middlewares.push(connect.static(base));
});
// Make directory browse-able.
var directory = options.directory || options.base[options.base.length - 1];
middlewares.push(connect.directory(directory));
return middlewares;
}
}
}
I need to be capable to deal with URLs with periods on the params used on Angular. Any help will be appreciated.
Thanks.