@supuwoerc/toolkit
    Preparing search index...

    Function ensureSuffix

    • 确保字符串以指定后缀结束;若未以该后缀结束则添加之。

      Ensure a string ends with the specified suffix; if not, append it.

      Parameters

      • suffix: string

        要确保的后缀 / suffix to ensure

      • str: string

        待处理的字符串 / input string

      Returns string

      如果 str 已以 suffix 结尾则返回原字符串,否则返回加上后缀后的新字符串 / original string if it already ends with suffix, otherwise the string with suffix appended

      // ensureSuffix('.js', 'file') -> 'file.js'