koel/resources/assets/js/utils/url.js

22 lines
383 B
JavaScript
Raw Normal View History

2016-07-07 13:54:20 +00:00
/**
* URL-related helpers
* @type {Object}
*/
export const url = {
/**
* Parse the song ID from a hash.
*
* @param {string} hash
*
* @return {string|boolean}
*/
parseSongId(hash = null) {
if (!hash) {
hash = window.location.hash;
}
const matches = hash.match(/#!\/song\/([a-f0-9]{32}$)/);
return matches ? matches[1] : false;
},
};