fix unicode regex

Add /g option like before. Remove manual export. Actually use it in the isNameValid function.
This commit is contained in:
Thomas Zarebczan 2019-06-02 22:55:52 -04:00
parent bd26d7ba44
commit b427ccfede
3 changed files with 7 additions and 10 deletions

9
dist/bundle.es.js vendored
View file

@ -822,7 +822,8 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
const channelNameMinLength = 1; const channelNameMinLength = 1;
const claimIdMaxLength = 40; const claimIdMaxLength = 40;
const regexInvalidURI = /[^A-Za-z0-9-]/g; // see https://spec.lbry.com/#urls
const regexInvalidURI = exports.regexInvalidURI = /[=&#:$@%?\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/gu;
const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/; const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/;
/** /**
@ -990,9 +991,8 @@ function isURIValid(URI) {
return parts && parts.claimName; return parts && parts.claimName;
} }
function isNameValid(claimName, checkCase = true) { function isNameValid(claimName) {
const regexp = new RegExp('^[a-z0-9-]+$', checkCase ? '' : 'i'); return !regexInvalidURI.test(claimName);
return regexp.test(claimName);
} }
function isURIClaimable(URI) { function isURIClaimable(URI) {
@ -3766,7 +3766,6 @@ exports.notificationsReducer = notificationsReducer;
exports.parseQueryParams = parseQueryParams; exports.parseQueryParams = parseQueryParams;
exports.parseURI = parseURI; exports.parseURI = parseURI;
exports.regexAddress = regexAddress; exports.regexAddress = regexAddress;
exports.regexInvalidURI = regexInvalidURI;
exports.savePosition = savePosition; exports.savePosition = savePosition;
exports.searchReducer = searchReducer; exports.searchReducer = searchReducer;
exports.selectAbandoningIds = selectAbandoningIds; exports.selectAbandoningIds = selectAbandoningIds;

View file

@ -23,7 +23,6 @@ export {
// common // common
export { Lbry }; export { Lbry };
export { export {
regexInvalidURI,
regexAddress, regexAddress,
parseURI, parseURI,
buildURI, buildURI,

View file

@ -2,7 +2,7 @@ const channelNameMinLength = 1;
const claimIdMaxLength = 40; const claimIdMaxLength = 40;
// see https://spec.lbry.com/#urls // see https://spec.lbry.com/#urls
const regexInvalidURI = (exports.regexInvalidURI = /[=&#:$@%?\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u); const regexInvalidURI = (exports.regexInvalidURI = /[=&#:$@%?\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/gu);
export const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/; export const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/;
/** /**
@ -201,9 +201,8 @@ export function isURIValid(URI) {
return parts && parts.claimName; return parts && parts.claimName;
} }
export function isNameValid(claimName, checkCase = true) { export function isNameValid(claimName) {
const regexp = new RegExp('^[a-z0-9-]+$', checkCase ? '' : 'i'); return !regexInvalidURI.test(claimName);
return regexp.test(claimName);
} }
export function isURIClaimable(URI) { export function isURIClaimable(URI) {