Skip to content

Commit

Permalink
Merge pull request #361 from y-van-z/mbs-8744
Browse files Browse the repository at this point in the history
Validate Generasia URLs (solves MBS-8744)
  • Loading branch information
mwiencek committed Oct 1, 2016
2 parents 4f2d541 + 47de1a5 commit 1b1072b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 13 additions & 3 deletions root/static/scripts/edit/URLCleanup.js
Expand Up @@ -730,7 +730,6 @@ const CLEANUPS = {
new RegExp("^(https?://)?(www\\.)?dhhu\\.dk", "i"),
new RegExp("^(https?://)?(www\\.)?openlibrary\\.org", "i"),
new RegExp("^(https?://)?(www\\.)?animenewsnetwork\\.com", "i"),
new RegExp("^(https?://)?(www\\.)?generasia\\.com/wiki/", "i"),
new RegExp("^(https?://)?(www\\.)?rockipedia\\.no", "i"),
new RegExp("^(https?://)?(www\\.)?whosampled\\.com", "i"),
new RegExp("^(https?://)?(www\\.)?maniadb\\.com", "i"),
Expand Down Expand Up @@ -790,11 +789,22 @@ const CLEANUPS = {
url = url.replace(/^(?:https?:\/\/)?(www\.)?openlibrary\.org\/(authors|books|works)\/(OL[0-9]+[AMW]\/)(.*)*$/, "http://openlibrary.org/$2/$3");
// Standardising Anime News Network
url = url.replace(/^(?:https?:\/\/)?(?:www\.)?animenewsnetwork\.com\/encyclopedia\/(people|company).php\?id=([0-9]+).*$/, "http://www.animenewsnetwork.com/encyclopedia/$1.php?id=$2");
// Standardising Generasia
url = url.replace(/^(?:https?:\/\/)?(?:www\.)?generasia\.com\/wiki\/(.*)$/, "http://www.generasia.com/wiki/$1");
return url;
}
},
generasia: {
match: [new RegExp("^(https?://)?(www\\.)?generasia\\.com/wiki/", "i")],
type: LINK_TYPES.otherdatabases,
clean: function (url) {
return url.replace(/^(?:https?:\/\/)?(?:www\.)?generasia\.com\/wiki\/(.*)$/, "http://www.generasia.com/wiki/$1");
},
validate: function (url, id) {
return id === LINK_TYPES.otherdatabases.artist
|| id === LINK_TYPES.otherdatabases.label
|| id === LINK_TYPES.otherdatabases.release_group
|| id === LINK_TYPES.otherdatabases.work;
}
},
soundtrackcollector: {
match: [new RegExp("^(https?://)?(www\\.)?soundtrackcollector\\.com", "i")],
type: LINK_TYPES.otherdatabases,
Expand Down
6 changes: 6 additions & 0 deletions root/static/scripts/tests/Control/URLCleanup.js
Expand Up @@ -635,6 +635,12 @@ test('URL cleanup component: auto-select, clean-up, and validation', {}, functio
input_entity_type: 'artist',
expected_relationship_type: 'otherdatabases',
expected_clean_url: 'http://www.generasia.com/wiki/Wink',
only_valid_entity_types: ['artist', 'label', 'release_group', 'work']
},
{
input_url: 'http://www.generasia.com/wiki/Nippon_Crown',
input_entity_type: 'label',
expected_relationship_type: 'otherdatabases',
},
{
input_url: 'http://www.generasia.com/wiki/Ai_ga_Tomaranai_~Turn_It_into_Love~',
Expand Down

0 comments on commit 1b1072b

Please sign in to comment.