Base de la BOEW

Questions ou commentaires?

Travail en cours

Cette page est un travail en cours.

Needs translation


Objet principal de la BOEW.

Language (wb.lang)

WET's language is derived from the html element's lang attribute. A formatted version of the page's language code is stored in the wb.lang variable.

By default, the variable's value will be derived from the first two characters of the page's language code. If a longer code is specified, it'll be re-used as the variable's value so long as it corresponds to one of WET's built-in languages (i.e. pt-BR for Portuguese [Brazilian] or zh-Hans for Chinese [Simplified]).

Implementations that want to provide custom i18n files for longer language codes (e.g. en-CA, en-US, etc) can do so by adding data-wb-core and data-lang-long="" attributes to WET's script element.

WET will also attempt to load an i18n file named after the variable. Plugins won't initialize if the i18n file fails to load.


Type Option Description How to configure Values
HTML attribue data-wb-core Customizes WET's core variables. Use with other data-* attributes. Add a data-wb-core attribute to WET's script element None
HTML attribue data-lang-long Extends wb.lang's support for long language codes (> 2 characters). Use with the data-wb-core attribute. Add a data-wb-core attribute to WET's script element Space-separated BCP 47 language codes


wb.findPotentialPII(str, scope, opts) - Find most common Personal Identifiable Information (PII) in a string

Find most common Personal Identifiable Information (PII) in a string and return either the cleaned string either true/false

This function can have the following parameters

  • str (required) - string representing the content that needs to be verified
  • scope this parameter can be:
    • either a boolean (required) - If passed as true will scrub the content
    • either an object (optional) - having the following properties (optional):
      • {string} any key name of the default patterns e.g. email, digits, etc. with the value 1. The function will only scrub the content that match the regex of the default patterns passed in this object

        The list of the regular expressions that will be applied by default:

        • digits
        • passport
        • email
        • postalCode
        • username
        • password
      • {regex} customCase - this param is a regular expression. It will search and replace the values corresponding that pattern
  • opts (optional) - the 3rd param of the function is an object that can contain the following properties (optional):
    • {boolean} isCustomExclusive - if the value is 1(true), it will scrubb only the custom regex if the regex is the only property of the scope object
    • {string} replaceWith - this string will replace the scrubbed content
    • {bolean} useFullBlock - if the is value 1(true), it will replace the scrubbed characters with the "█" symbol;

Working example

wb.findPotentialPII( ", phone:123 123 1234", true )

It will return: "email:, phone:"

	wb.findPotentialPII( ", phone:123 123 1234", false )

It will return: true

wb.findPotentialPII( ", phone:123 123 1234", { email:1 }{ replaceWith: [REDACTED/CAVIARDÉ] } )

It will return:"email:[REDACTED/CAVIARDÉ], phone:123 123 1234"

wb.findPotentialPII( ", phone:123 123 1234, numéro de cas 12345678", { "customCase":/\b(?:case[\s-]?number[\s\-\\.]?(?:\d{5,10}))|(?:numéro[\s-]?de[\s-]?cas[\s\-\\.]?(?:\d{5,10}))/ig }, { useFullBlock:1})

It will return: "phone:████████████, email:█████████████, postalCode:██████, ██████████████████████"

Source code

WET core source code on GitHub

Date de modification :