mirror of
https://github.com/koel/koel
synced 2024-12-30 14:33:06 +00:00
22 lines
383 B
JavaScript
22 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;
|
||
|
},
|
||
|
};
|