Skip to content

Commit cfe6812

Browse files
authored
MBS-11622: Clean up Apple Music label URLs (metabrainz#2086)
We shouldn't really autoselect-validate these; while we still don't have a streaming page for labels, this seems like a good indication we could use one. But this adds cleanup for now.
1 parent 0d0df67 commit cfe6812

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

root/static/scripts/edit/URLCleanup.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ const CLEANUPS = {
725725
'applemusic': {
726726
match: [new RegExp('^(https?://)?([^/]+\\.)?music\\.apple\\.com/', 'i')],
727727
clean: function (url) {
728-
url = url.replace(/^https?:\/\/(?:(?:beta|geo)\.)?music\.apple\.com\/([a-z]{2}\/)?(artist|album|author|music-video)\/(?:[^?#\/]+\/)?(?:id)?([0-9]+)(?:\?.*)?$/, 'https://music.apple.com/$1$2/$3');
728+
url = url.replace(/^https?:\/\/(?:(?:beta|geo)\.)?music\.apple\.com\/([a-z]{2}\/)?(artist|album|author|label|music-video)\/(?:[^?#\/]+\/)?(?:id)?([0-9]+)(?:\?.*)?$/, 'https://music.apple.com/$1$2/$3');
729729
// US page is the default, add its country-code to clarify (MBS-10623)
730730
url = url.replace(/^(https:\/\/music\.apple\.com)\/([a-z-]{3,})\//, '$1/us/$2/');
731731
return url;

root/static/scripts/tests/Control/URLCleanup.js

+4
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ const testData = [
400400
input_url: 'https://beta.music.apple.com/ca/artist/imposs/205021452',
401401
expected_clean_url: 'https://music.apple.com/ca/artist/205021452',
402402
},
403+
{
404+
input_url: 'https://music.apple.com/us/label/ghostly-international/1543968172',
405+
expected_clean_url: 'https://music.apple.com/us/label/1543968172',
406+
},
403407
{
404408
input_url: 'https://music.apple.com/ee/music-video/black-and-yellow/539886832?uo=4&mt=5&app=music',
405409
expected_clean_url: 'https://music.apple.com/ee/music-video/539886832',

0 commit comments

Comments
 (0)