fix(ui): use div for fragment, check lastfm url for artist page (#4980)
* fix(ui): use div for fragment, check lastfm url for artist page * use span instead of div for better compat * fix: implement isLastFmURL utility and add tests for URL validation --------- Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -44,3 +44,16 @@ export const shareCoverUrl = (id, square) => {
|
||||
}
|
||||
|
||||
export const docsUrl = (path) => `https://www.navidrome.org${path}`
|
||||
|
||||
export const isLastFmURL = (url) => {
|
||||
try {
|
||||
const parsed = new URL(url)
|
||||
return (
|
||||
(parsed.protocol === 'http:' || parsed.protocol === 'https:') &&
|
||||
(parsed.hostname === 'last.fm' || parsed.hostname.endsWith('.last.fm')) &&
|
||||
parsed.pathname.startsWith('/music/')
|
||||
)
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user