Ensure prefix, if str does not start with prefix, it will be added
确保前缀,如果字符串不以前缀开头,则将添加前缀。
The string to check. 要检查的字符串
The prefix to ensure. 要确保的前缀
The string with the prefix ensured. 确保前缀后的字符串
ensurePrefix('example.com', 'http://') // => http://example.comensurePrefix('//example.com', '//') // => //example.com Copy
ensurePrefix('example.com', 'http://') // => http://example.comensurePrefix('//example.com', '//') // => //example.com
Ensure prefix, if str does not start with prefix, it will be added
确保前缀,如果字符串不以前缀开头,则将添加前缀。