I'm building a code playground for fun like jsfiddle. One thing I'm not so familiar with is url shortening where a unique string of characters is generated ie jsfiddle.net/QyqvC/ .
I believe I found a node.js solution for this here: http://pravin.paratey.com/posts/building-url-shortener However, I'm not sure how to make it so that when the url with the unique characers like this one "jsfiddle.net/QyqvC/ ", is visited, the data that's suppose to load for that specific page (html, css, javascript in their boxes) will load like with jsfiddle.
One solution I thought of was generating unique characters in javascript then having a js script modify the url from mysite.com to mysite.com/AqUeFg with those unique characters and then storing the code that's currently in the code boxes (html, js, css) along with those unique characters (AqUeFg) in my database and then I would have a self invoking anonymous function that would check for the unique characters at the end of the url after "/" when a page loads and then this would be used to find the data in my db (html, css, js) and display it in the appropriate boxes.
I'm not sure if this solution is any good. Is there a better way to do this? I feel like there probably is and also, with whatever solution I use, how can I avoid a scenario where I run out of unique characters?