title: Polymer Starter Kit 1.2.2 breaking on load because of regex replace
body: <p>it was working fine then after I switched back to gulp serve from apache I got an undefined error in page.js in a regex replace</p>
  
  <pre><code>if (window.location.port ==='') {
      page.base(app.baseUrl.replace(/\$/, ''));
  }
  </code></pre>
  
  <p>because app.baseUrl is ''.  the code is unedited but the baseurl doesn't have a "/" in it for some reason now.  the error occurse as soon a i run gulp serve.  webcomponentsready fires and is caught in routing.html.  it breaks when this calls page.js here:</p>
  
  <pre><code>page(app.baseUrl, function() {
    app.route = 'home';
  });
  </code></pre>
  
  <p>first of all, shouldn't it not break if there isn't a slash in the url?  second, what determines the baseurl when you use gulp serve?</p>
  
  <p>more routing.html</p>
  
  <pre><code>window.addEventListener('WebComponentsReady', function() {
  
  // We use Page.js for routing. This is a Micro
  // client-side router inspired by the Express router
  // More info: https://visionmedia.github.io/page.js/
  
  // Removes end / from app.baseUrl which page.base requires for production
  if (window.location.port === '') {  // if production
    page.base(app.baseUrl.replace(/\/$/, ''));
  }
  
  // Middleware
  function scrollToTop(ctx, next) {
    app.scrollPageToTop();
    next();
  }
   function closeDrawer(ctx, next) {
    app.closeDrawer();
    next();
  }
  
  // Routes
  page('*', scrollToTop, closeDrawer, function(ctx, next) {
    next();
  });
  
  page('/', function() {
    app.route = 'home';
  });
  
  page(app.baseUrl, function() {
    app.route = 'home';
  });
  
  page('/users', function() {
    app.route = 'users';
  });
  
  page('/users/:name', function(data) {
    app.route = 'user-info';
    app.params = data.params;
  });
  
  page('/contact', function() {
    app.route = 'contact';
  });
  
  // 404
  page('*', function() {
    app.$.toast.text = 'Can\'t find: ' + window.location.href  + '. Redirected you to Home Page';
    app.$.toast.show();
    page.redirect(app.baseUrl);
  });
  
  // add #! before urls
  page({
    hashbang: true
  });
  </code></pre>
  
  <p>});</p>