Improvement in regex (#1431)

This commit is contained in:
Xavier Guimard 2018-06-20 06:56:32 +02:00
parent b823c888e2
commit 783349a39f
3 changed files with 8 additions and 8 deletions

View File

@ -60,8 +60,8 @@ setOrder = ->
# Function used to remove an OIDC consent # Function used to remove an OIDC consent
removeOidcConsent = (partner) -> removeOidcConsent = (partner) ->
r = new RegExp partner, 'g' r = new RegExp "\b#{partner}\b,?"
datas['oidcConsents'] = datas['oidcConsents'].replace(r,'').replace(/,+/,',').replace(/^,/,'').replace(/,$/,'') datas['oidcConsents'] = datas['oidcConsents'].replace(r,'').replace(/,$/,'')
setKey '_oidcConnectedRP', datas['oidcConsents'] setKey '_oidcConnectedRP', datas['oidcConsents']
# Success # Success
, () -> , () ->

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.9.3 // Generated by CoffeeScript 1.12.7
/* /*
LemonLDAP::NG Portal jQuery scripts LemonLDAP::NG Portal jQuery scripts
@ -59,8 +59,8 @@ LemonLDAP::NG Portal jQuery scripts
results.push(values[k] = tmp[k]); results.push(values[k] = tmp[k]);
} }
return results; return results;
} catch (_error) { } catch (error1) {
e = _error; e = error1;
console.log('Parsing error', e); console.log('Parsing error', e);
return console.log('JSON', $(this).text()); return console.log('JSON', $(this).text());
} }
@ -76,8 +76,8 @@ LemonLDAP::NG Portal jQuery scripts
removeOidcConsent = function(partner) { removeOidcConsent = function(partner) {
var r; var r;
r = new RegExp(partner, 'g'); r = new RegExp("\b" + partner + "\b,?");
datas['oidcConsents'] = datas['oidcConsents'].replace(r, '').replace(/,+/, ',').replace(/^,/, '').replace(/,$/, ''); datas['oidcConsents'] = datas['oidcConsents'].replace(r, '').replace(/,$/, '');
return setKey('_oidcConnectedRP', datas['oidcConsents'], function() { return setKey('_oidcConnectedRP', datas['oidcConsents'], function() {
return $("[partner='" + partner + "']").hide(); return $("[partner='" + partner + "']").hide();
}, function(j, s, e) { }, function(j, s, e) {

File diff suppressed because one or more lines are too long