Adopts Prezi URL check to match default share links.

This commit is contained in:
paweldomas 2014-03-27 18:09:05 +01:00
parent 81df90897f
commit 2cbdc43e78
2 changed files with 11 additions and 12 deletions

View File

@ -112,7 +112,7 @@ var Prezi = (function (my) {
else { else {
var presIdTmp = urlValue.substring( var presIdTmp = urlValue.substring(
urlValue.indexOf("prezi.com/") + 10); urlValue.indexOf("prezi.com/") + 10);
if (!Util.isAlphanumeric(presIdTmp) if (!isAlphanumeric(presIdTmp)
|| presIdTmp.indexOf('/') < 2) { || presIdTmp.indexOf('/') < 2) {
$.prompt.goToState('state1'); $.prompt.goToState('state1');
return false; return false;
@ -258,6 +258,16 @@ var Prezi = (function (my) {
} }
}; };
/**
* Indicates if the given string is an alphanumeric string.
* Note that some special characters are also allowed (-, _ , /, &, ?, =, ;) for the
* purpose of checking URIs.
*/
function isAlphanumeric(unsafeText) {
var regex = /^[a-z0-9-_\/&\?=;]+$/i;
return regex.test(unsafeText);
}
/** /**
* Returns the presentation id from the given url. * Returns the presentation id from the given url.
*/ */

11
util.js
View File

@ -46,17 +46,6 @@ var Util = (function (my) {
return $('<div/>').text(unsafeText).html(); return $('<div/>').text(unsafeText).html();
}; };
/**
* Indicates if the given string is an alphanumeric string.
* Note that some special characters are also allowed (-, _ , /) for the
* purpose of checking URIs. (FIXME: This should maybe moved to another not
* so generic method in the future.)
*/
my.isAlphanumeric = function(unsafeText) {
var regex = /^[a-z0-9-_\/]+$/i;
return regex.test(unsafeText);
};
/** /**
* Returns the available video width. * Returns the available video width.
*/ */