Clever Way of Extract URL Information in JS

Here’s a nice little way to extract URL information from a string. Rather than trying to parse/split the string into its parts (protocol, host, path, query) just use an a tag and access it’s properties to get the relative information you want.

1
2
3
4
5
6
7
8
9
var url    = 'https://www.google.co.uk/search?q=hello'
var anchor = document.createElement('a');

anchor.href = url;

var protocol = anchor.protocol; // 'https:'
var host     = anchor.hostname; // 'google.co.uk'
var path     = anchor.pathname; // '/search'
var query    = anchor.search;   // '?q=hello'

Simples.

js, url
Comments

Top 10 Languages in 2014, So Lynda Says

Lynda.com the online training site have published what they think are going be the top 10 languages to know this year. All your usual suspects are in there but what has suprised me is the order of the list. Is this is a list set by trends in 2013, if so it seems to be that Java is still considered cool.

Have a look and see what you think?

Top 10 Programming Languages to know in 2014

Comments

Goodbye Php, Hello Node.js!

Summer 2013

The start of summer ‘13 saw a shift in my career. Near twelve years in the making to become a Php developer, twelve years that started in my bedroom. From building bit torrent sites, practicing with the latest MVC frameworks, getting through several years of study and a few in the actual industry, I took a chance to become a ninja.

I’ve done a bit of JavaScript, obviously being a web developer, but never really understood the language and it’s nature. I never stopped to think about the simplicity of the prototypal inheritance it offers, or just how great closures are.

Read on →
Comments