<commit_before>let logos = require('./logos');
// We depend on logos being compiled to a js script so that it can be trivially included
// in the StellarTerm client without webpack

// Constraints: Data should be easily serializable into JSON (no references to each other)
// directory.js should not depend on creating objects with StellarSdk (though its methods should support reading them)

// Note: the DirectoryBuilder concept of slug is slightly different from that of Stellarify
// slugs here can only have the format `code-accountId`

class DirectoryBuilder {
  constructor() {
    this.anchors = {};
    this.destinations = {};
    this.assets = {};
    this.issuers = {};
    this.pairs = {};

    // Special anchors aren't really anchors at all!
    this.nativeAnchor = {
      name: 'Stellar Network',
      website: 'https://www.stellar.org/lumens/',
      logo: logos['stellar'],
      color: '#08b5e5',
    };
    this.nativeAsset = {
      code: 'XLM',
      issuer: null,
      domain: 'native',
    };

    this.unknownAnchor = {
      name: 'unknown',
      logo: logos.unknown,
      assets: {},
    };
  }

  toJson() {
    return JSON.stringify(this, null, 2);
  }

  addAnchor(details) {
    if (this.anchors[details.domain] !== undefined) {
      throw new Error('Duplicate anchor in directory: ' + details.domain);
    }
    if (logos[details.logo] === undefined) {
      throw new Error('Missing logo file: ' + details.logo);
    }
    if (details.website.indexOf('http://') !== -1) {
      throw new Error('Website URL must use https://');
    }
    if (details.website.indexOf(details.domain) == -1) {
      throw new Error('Website URL of anchor must contain the anchor domain');
    }<commit_msg>Add check to require display name in directory<commit_after>let logos = require('./logos');
// We depend on logos being compiled to a js script so that it can be trivially included
// in the StellarTerm client without webpack

// Constraints: Data should be easily serializable into JSON (no references to each other)
// directory.js should not depend on creating objects with StellarSdk (though its methods should support reading them)

// Note: the DirectoryBuilder concept of slug is slightly different from that of Stellarify
// slugs here can only have the format `code-accountId`

class DirectoryBuilder {
  constructor() {
    this.anchors = {};
    this.destinations = {};
    this.assets = {};
    this.issuers = {};
    this.pairs = {};

    // Special anchors aren't really anchors at all!
    this.nativeAnchor = {
      name: 'Stellar Network',
      website: 'https://www.stellar.org/lumens/',
      logo: logos['stellar'],
      color: '#08b5e5',
    };
    this.nativeAsset = {
      code: 'XLM',
      issuer: null,
      domain: 'native',
    };

    this.unknownAnchor = {
      name: 'unknown',
      logo: logos.unknown,
      assets: {},
    };
  }

  toJson() {
    return JSON.stringify(this, null, 2);
  }

  addAnchor(details) {
    if (this.anchors[details.domain] !== undefined) {
      throw new Error('Duplicate anchor in directory: ' + details.domain);
    }
    if (logos[details.logo] === undefined) {
      throw new Error('Missing logo file: ' + details.logo);
    }
    if (details.website.indexOf('http://') !== -1) {
      throw new Error('Website URL must use https://');
    }
    if (details.website.indexOf(details.domain) == -1) {
      throw new Error('Website URL of anchor must contain the anchor domain');
    }
    if (!details.displayName) {
      throw new Error('Display name is required for anchor: ' + details.domain);
    }

{'fraction_non_alphanumeric': 0.12656119900083265, 'fraction_numerical': 0.0038856508465167916, 'mean_word_length': 2.8586723768736615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4413743', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1019, 'n_words': 344}