koel/resources/assets/js/utils/url.js
2016-07-07 21:54:20 +08:00

21 lines
383 B
JavaScript

/**
* 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;
},
};