safeEncodeURIComponent

GitHub查看源码
安全地编码 URL 组件,与原生 encodeURIComponent 行为兼容,编码失败时不抛出异常。

用法

safeEncodeURIComponent 函数用于编码 URL 组件(安全版本)。

import { safeEncodeURIComponent } from '@movk/core'

safeEncodeURIComponent('中文') // '%E4%B8%AD%E6%96%87'
safeEncodeURIComponent('hello world') // 'hello%20world'

API

safeEncodeURIComponent(str)

编码 URL 组件(安全版本)。

参数

str
string required
要编码的字符串。

返回值

返回值
string
编码后的字符串。

Changelog

No recent changes
Copyright © 2024 - 2026 YiXuan - MIT License