How to use the xregexp.XRegExp.build function in xregexp

To help you get started, we’ve selected a few xregexp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vf1 / media-server / src / ui / Library.js View on Github external
getErrors: function () {
        
        if (!this.mountpathre || !this.pathre) {
            this.mountpathre = xRegExp.build('^(?:(?:\\/)|(?:(?:[\\/]{{char}}+)+))$', { char: '[_0-9\\p{L}\\-\\.\\s]' });
            this.pathre = xRegExp.build('^(?:[a-zA-Z]\\:|[\\/])(?:[\\/]{{char}}+)+$', { char: '[_0-9\\p{L}\\-\\.\\s]' });
        }
        
        var errors = {
            mountpath: !this.mountpathre.test(this.state.edit.mountpath),
            path: !this.pathre.test(this.state.edit.path),
            type: !(/music|path/.test(this.state.edit.type)),
            messages: []
        };
        
        if (this.state.edit.mountpath !== '' || this.state.edit.path !== '' || this.state.edit.type !== '') {
            
            if (errors.mountpath) {
                errors.messages.push('The mount path expected, e.g. /music/retro');
            }
github vf1 / media-server / src / ui / Library.js View on Github external
getErrors: function () {
        
        if (!this.mountpathre || !this.pathre) {
            this.mountpathre = xRegExp.build('^(?:(?:\\/)|(?:(?:[\\/]{{char}}+)+))$', { char: '[_0-9\\p{L}\\-\\.\\s]' });
            this.pathre = xRegExp.build('^(?:[a-zA-Z]\\:|[\\/])(?:[\\/]{{char}}+)+$', { char: '[_0-9\\p{L}\\-\\.\\s]' });
        }
        
        var errors = {
            mountpath: !this.mountpathre.test(this.state.edit.mountpath),
            path: !this.pathre.test(this.state.edit.path),
            type: !(/music|path/.test(this.state.edit.type)),
            messages: []
        };
        
        if (this.state.edit.mountpath !== '' || this.state.edit.path !== '' || this.state.edit.type !== '') {
            
            if (errors.mountpath) {
                errors.messages.push('The mount path expected, e.g. /music/retro');
            }

            if (errors.path) {