Skip to content

Commit ceabb5d

Browse files
committed
MBS-14279: Support Amazon Belgium links
There seem to be no Amazon Music Belgium pages, so not supporting those. Amusingly, apparently Amazon probably couldn't get amazon.be for a decent price, so they went for amazon.com.be - it seems that com.be is not a valid public suffix for Belgium, but a private domain Amazon probably owns. As such, we need to have amazon.com.be separately in the hostname options, since the hostname is not seen by amazon.*.
1 parent 8737b40 commit ceabb5d

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

lib/MusicBrainz/Server/Data/URL.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ my %URL_SPECIALIZATIONS = (
2424
'ACUM' => qr{^https?://nocs\.acum\.org\.il/}i,
2525
'Allmusic' => qr{^https?://(?:www\.)?allmusic\.com/}i,
2626
'AlloCine' => qr{^https?://(?:www\.)?allocine\.fr/}i,
27-
'AmazonMusic' => qr{^https:\/\/music\.amazon\.(?:ae|at|com\.au|com\.br|ca|cn|com|de|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|se|sg|com\.tr|co\.uk)/}i,
27+
'AmazonMusic' => qr{^https:\/\/music\.amazon\.(?:ae|at|com\.au|com\.be|com\.br|ca|cn|com|de|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|se|sg|com\.tr|co\.uk)/}i,
2828
'Anghami' => qr{^https?://([^/]+\.)?anghami\.com/}i,
2929
'AniDB' => qr{^https?://(?:www\.)?anidb\.net/}i,
3030
'AniList' => qr{^https?://(?:www\.)?anilist\.co/}i,

lib/MusicBrainz/Server/Report/BadAmazonURLs.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ sub query
2020
JOIN release r ON lru.entity0 = r.id
2121
WHERE
2222
url ~ 'amazon\.' AND
23-
url !~ '^https?://www\.amazon\.(ae|at|com\.au|com\.br|ca|cn|com|de|eg|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|sa|se|sg|com\.tr|co\.uk)/gp/product/[0-9A-Z]{10}$' AND
24-
url !~ '^https?://music\.amazon\.(ae|at|com\.au|com\.br|ca|cn|com|de|eg|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|sa|se|sg|com\.tr|co\.uk)'
23+
url !~ '^https?://www\.amazon\.(ae|at|com\.au|com\.be|com\.br|ca|cn|com|de|eg|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|sa|se|sg|com\.tr|co\.uk)/gp/product/[0-9A-Z]{10}$' AND
24+
url !~ '^https?://music\.amazon\.(ae|at|com\.au|com\.be|com\.br|ca|cn|com|de|eg|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|sa|se|sg|com\.tr|co\.uk)'
2525
};
2626
}
2727

root/static/scripts/edit/URLCleanup.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,9 @@ export const CLEANUPS: CleanupEntries = {
662662
},
663663
},
664664
'amazon': {
665-
hostname: ['amazon.*', 'amzn.com', 'amzn.to'],
665+
hostname: ['amazon.*', 'amazon.com.be', 'amzn.com', 'amzn.to'],
666666
match: [
667-
/^(https?:\/\/)?(((?!music)[^/])+\.)?(amazon\.(ae|at|com\.au|com\.br|ca|cn|com|de|eg|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|sa|se|sg|com\.tr|co\.uk)|amzn\.com)/i,
667+
/^(https?:\/\/)?(((?!music)[^/])+\.)?(amazon\.(ae|at|com\.au|com\.be|com\.br|ca|cn|com|de|eg|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|sa|se|sg|com\.tr|co\.uk)|amzn\.com)/i,
668668
/^(https?:\/\/)?([^/]+\.)?amzn\.to/i,
669669
],
670670
restrict: [LINK_TYPES.amazon],
@@ -729,7 +729,7 @@ export const CLEANUPS: CleanupEntries = {
729729

730730
// If you change this, please update the BadAmazonURLs report.
731731
return {
732-
result: /^https:\/\/www\.amazon\.(ae|at|com\.au|com\.br|ca|cn|com|de|eg|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|sa|se|sg|com\.tr|co\.uk)\//.test(url),
732+
result: /^https:\/\/www\.amazon\.(ae|at|com\.au|com\.be|com\.br|ca|cn|com|de|eg|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|sa|se|sg|com\.tr|co\.uk)\//.test(url),
733733
target: ERROR_TARGETS.URL,
734734
};
735735
},
@@ -765,7 +765,7 @@ export const CLEANUPS: CleanupEntries = {
765765
},
766766
validate(url, id) {
767767
// If you change this, please update the BadAmazonURLs report.
768-
const m = /^https:\/\/music\.amazon\.(?:ae|at|com\.au|com\.br|ca|cn|com|de|eg|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|sa|se|sg|com\.tr|co\.uk)\/(albums|artists|tracks)/.exec(url);
768+
const m = /^https:\/\/music\.amazon\.(?:ae|at|com\.au|com\.be|com\.br|ca|cn|com|de|eg|es|fr|in|it|jp|co\.jp|com\.mx|nl|pl|sa|se|sg|com\.tr|co\.uk)\/(albums|artists|tracks)/.exec(url);
769769
if (m) {
770770
const prefix = m[1];
771771
switch (id) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,12 @@ const testData = [
432432
expected_clean_url: 'https://www.amazon.co.uk/gp/product/B00005JIWP',
433433
only_valid_entity_types: ['release'],
434434
},
435+
{
436+
input_url: 'https://www.amazon.com.be/-/en/How-Replace-Deus/dp/B0BLFT2LBP/ref=sr_1_1?crid=1O1BWTMB6AFR4&dib=eyJ2IjoiMSJ9.2LhGteFs50LX0oL2ndp7U6_QpTCvDBwk23qlzZXsrxGeivmajYfscdK7vxX3LUP3mfLgapmkFseppCmClI25vZMTqUMdu9KfPvEbDPvt38ZqFQol_jk3aNumTW_Qwrk6H-vEOwfwnxRbH8RT_tnIAxhl30990wo1OBNJPlaFXPgNhdETw8ZWdg76aM8OlO8Uka9eEhm0UnHmc6KyNw1aGR0s2kB1lXhBBLOMrJjM3rl51VAiXZHe27v_nae_MhdV2DRL93gxbvE3zhvf87B7rYhKzPYkGy_ordKJe0zpQn8.86BcKf5L1IlDejlLZjrmoiJAP3qrtY_qswWw4BBzIJc&dib_tag=se&keywords=deus+cd&qid=1772453811&sprefix=deus%2Caps%2C129&sr=8-1',
437+
input_entity_type: 'release',
438+
expected_relationship_type: 'amazon',
439+
expected_clean_url: 'https://www.amazon.com.be/gp/product/B0BLFT2LBP',
440+
},
435441
{
436442
input_url: 'http://amazon.com.br/dp/B00T8E47G2',
437443
input_entity_type: 'release',

0 commit comments

Comments
 (0)