@pengzhanbo/utils - v3.4.1
    Preparing search index...

    Function ensurePrefix

    • Ensure prefix, if str does not start with prefix, it will be added

      确保前缀,如果字符串不以前缀开头,则将添加前缀。

      Parameters

      • str: string

        The string to check. 要检查的字符串

      • prefix: string

        The prefix to ensure. 要确保的前缀

      Returns string

      The string with the prefix ensured. 确保前缀后的字符串

      ensurePrefix('example.com', 'http://') // => http://example.com
      ensurePrefix('//example.com', '//') // => //example.com