cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
<h1>MiniMe</h1>
<label for="url-input">Input a URL to Minify</label>
<div class="input-group">
  <span class="input-group-addon" id="basic-addon3">https://</span>
  <input type="text" class="form-control" id="url-input" placeholder="robertvalmassoi.com">
  <span class="input-group-addon btn btn-info" id="mini-btn">MiniMe!</span>
</div>

<label for="url-output">MiniMe URL</label>
<div class="input-group">
  <input type="text" class="form-control" id="url-output">
  <span class="input-group-addon btn btn-info" id="copy-btn">copy</span>
</div>

<div id="git">
<a href="https://github.com/valmassoi/url-shortener" target="_blank" id="git">
    <button type="button" class="btn btn-default btn-lg">
  <span aria-hidden="true"></span><i class="fa fa-github"></i> Github
  </button></a>
  <p><br>Using my API - <a href="https://minime.herokuapp.com/" target="_blank">minime.herokuapp.com/</a></p>
</div>
            
          
!
            
              body
  padding: 20px
label
  padding-top: 20px
  min-width: 300px !important
#form-control
  min-width: 300px !important
#copy-btn
  min-width: 85px
#mini-btn
  background-color: #2E6F9A !important
  width: 85px
  &:hover
    background-color: #217DBB !important
#git
  margin-top: 50px
  text-align: center
            
          
!
            
              const baseUrl = "http://cors.io/?u=https://minime.herokuapp.com/new/"
let input = "https://www.google.com"
let url = baseUrl + input


$(function() {

})

function urlMod(origUrl){
  let regexp = /^(https?):\/\//
  let url = origUrl
  if (regexp.test(url))
    console.log("begins with http")
  else//add http://
    url = 'http://' + url 
  return url
}
function urlCheck(url){
  let regexpTwo = /^(https?):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
  return regexpTwo.test(url)
}

function api(origUrl){
  $.getJSON(baseUrl+origUrl, function (data) {
    console.log(data)
    $('#url-output').val(data.short_url)
  })
}

$("#mini-btn").on("click", function(){
  miniMe()
})
$("#url-output").css("cursor", "default")
function miniMe(){
  console.log("mini me!: "+ $('#url-input').val())
  let origUrl = $('#url-input').val()
  let url = urlMod(origUrl)
  if (urlCheck(url))
    api(url)
  else
    console.log("bad url")
}

$("#copy-btn").on("click", function(){
  let copyTextarea = document.querySelector('#url-output')
  copyTextarea.select()
  try {
    var successful = document.execCommand('copy')
    var msg = successful ? 'successful' : 'unsuccessful'
    console.log('Copying text command was ' + msg)
  } catch (err) {
    console.log('Oops, unable to copy')
  }
})

$("#url-input").keydown(function(e) {
    if(e.keyCode == 13){
      miniMe()
    }
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console