Jonas Kress (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/355206 )
Change subject: Make entity detection not so strict in FormatterHelper
......................................................................
Make entity detection not so strict in FormatterHelper
Also deprecates isExploreUrl method.
Change-Id: I0a9c4ce52da47be3f6fd50057ed651f28e067a57
---
M wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js
1 file changed, 15 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui
refs/changes/06/355206/1
diff --git a/wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js
b/wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js
index 355f0a5..b75a7fd 100644
--- a/wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js
+++ b/wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js
@@ -7,7 +7,7 @@
wikibase.queryService.ui.resultBrowser.helper.FormatterHelper = ( function( $,
moment ) {
'use strict';
- var EXPLORE_URL = 'http://www.wikidata.org/entity/',
+ var REGEX_ENTITY_URI =
/(https|http):\/\/www.wikidata.org\/entity\/([A-Z0-9])+/i,
COMMONS_FILE_PATH =
'http://commons.wikimedia.org/wiki/special:filepath/',
COMMONS_FILE_PATH_MEDIAVIEWER =
'https://commons.wikimedia.org/wiki/File:{FILENAME}',
DATATYPE_DATETIME = 'http://www.w3.org/2001/XMLSchema#dateTime',
@@ -128,7 +128,7 @@
} else {
$link.text( data.label || this.abbreviateUri(
value ) );
- if ( this.isExploreUrl( value ) ) {
+ if ( this.isEntityUri( value ) ) {
$html.prepend(
this.createExploreButton( value ), ' ' );
}
}
@@ -211,11 +211,22 @@
/**
* Checks whether given URL is available for explorer
*
+ * @deprecated
* @param {string} url
* @return {boolean}
*/
SELF.prototype.isExploreUrl = function( url ) {
- return typeof url === 'string' && url.startsWith( EXPLORE_URL );
+ return this.isEntity( url );
+ };
+
+ /**
+ * Checks whether given URI is an Wikidata entity URI
+ *
+ * @param {string} uri
+ * @return {boolean}
+ */
+ SELF.prototype.isEntityUri = function( uri ) {
+ return typeof uri === 'string' && uri.match( REGEX_ENTITY_URI );
};
/**
@@ -398,7 +409,7 @@
return false;
}
- return this.isExploreUrl( cell.value );
+ return this.isEntityUri( cell.value );
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/355206
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a9c4ce52da47be3f6fd50057ed651f28e067a57
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Jonas Kress (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits