javascript - A better way to create a URL based on window.location.href? -


the code have right now:

    setdomain: function() {         var currenturl = window.location.href;         var ufragment  = currenturl.split('\n');         var domain = "";          if(currenturl.match(/<removed>/)) {             domain = ufragment[0] + '//' + ufragment[2] + '/' + ufragment[3] + '/';         } else {             domain = ufragment[0] + '//' + ufragment[2] + '/';         }          this.domain = domain;     }, 

this function decides domain script should use. @ work, have internal testing sites subdomain.domain.tld/sitename , subdomain.domain.tld:81/sitename

the code splits current url / , appends http://, domain.subdomain.tld, , sitename

i looking solution because using ufragment[0], while need, ugly. suggestions?


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -