javascript - How to remove "http://" from domain name inside view -


how can remove "http://" beginning of url inside view in angularjs app?

i have urls in database like:

http://example.com/ http://example.com example.com 

but need show

example.com 

inside view.

this deals http , https or other url. uses built-in url class, handle of things haven't thought of correctly.

  app.filter('domain', function () {     return function (input) {       try {         var url = new url(input);         return url.hostname;       } catch (domexception) {         // malformed url. return original (or else).         return input; }       };     }); 

urls correct , might not have thought of:

you may not need them now, using correct library function means app won't break unexpectedly in future when tries use else.


Comments

Popular posts from this blog

How do you convert a timestamp into a datetime in python with the correct timezone? -

how to display 2 form fields on same line with bootstrap -

c# - how to use buttonedit in devexpress gridcontrol -