<commit_before>// Description:
//
// ## What
//
// This script replaces all references to the Unleash ushosted instance in the
// generated OpenAPI docs. It removes extra path segments (such as leading
// `/ushosted` instances) and replaces the ushosted base url with something
// user-agnostic.
//
// ## Why
//
// When we host the OpenAPI docs in our official documentation, the generated
// docs shouldn't necessarily point at _one specific instance_, and especially
// not one that the reader is unlikely to ever use. Instead, we can remove all
// the bits that are specific to the generation source we use, and make the docs
// easier to use. In particular, removing the leading `/ushosted` is likely to
// save us loooots of questions.
const replace = require('replace-in-file');

const options = {
    files: 'docs/reference/api/**/*.api.mdx',
    from: [
        /\/ushosted/g,
        /"https:\/\/us.app.unleash-hosted.com(\/ushosted)?"/g,
        '"path":["ushosted","api"',
    ],
    to: ['', '"<your-unleash-url>"', '"path":["api"'],
};

replace(options);<commit_msg>Fix(#1391): fix edge case URLs in code samples (#2078)<commit_after>// Description:
//
// ## What
//
// This script replaces all references to the Unleash ushosted instance in the
// generated OpenAPI docs. It removes extra path segments (such as leading
// `/ushosted` instances) and replaces the ushosted base url with something
// user-agnostic.
//
// ## Why
//
// When we host the OpenAPI docs in our official documentation, the generated
// docs shouldn't necessarily point at _one specific instance_, and especially
// not one that the reader is unlikely to ever use. Instead, we can remove all
// the bits that are specific to the generation source we use, and make the docs
// easier to use. In particular, removing the leading `/ushosted` is likely to
// save us loooots of questions.
const replace = require('replace-in-file');

const options = {
    files: 'docs/reference/api/**/*.api.mdx',
    from: [
        /\/ushosted/g,
        /"https:\/\/us.app.unleash-hosted.com(\/ushosted)?"/g,
        '"path":["ushosted",',
    ],
    to: ['', '"<your-unleash-url>"', '"path":['],
};

replace(options);
{'fraction_non_alphanumeric': 0.14207400639561443, 'fraction_numerical': 0.003654636820465966, 'mean_word_length': 3.203454894433781, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2991642', 'n_tokens_mistral': 667, 'n_tokens_neox': 639, 'n_words': 251}