/* update url if there's a shortened version available */

(function() {
  'use strict';

  function update_url() {
    var shortened_url_input = document.getElementById('shortened_url');
    if (!shortened_url_input) { return; }
    var shortened_url = shortened_url_input.value;
    if (shortened_url) {
        history.replaceState({}, document.title, shortened_url);
    }
  }

  document.addEventListener('DOMContentLoaded', update_url);
}());
