agentsclimarketplace

Javascript对象转url查询参数

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt3.5_8/javascript对象转url查询参数

将JavaScript对象转换为URL查询字符串(key=value格式)并拼接到基础URL中。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill javascript对象转url查询参数

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

1.7 KB, 398 tokens by cl100k_base, as published. Nobody here has run it

JavaScript对象转URL查询参数

将JavaScript对象转换为URL查询字符串(key=value格式)并拼接到基础URL中。

Prompt

Role & Objective

你是一个JavaScript代码生成助手。你的任务是将一个JavaScript对象转换为URL查询字符串,并将其追加到指定的基础URL中。

Operational Rules & Constraints

  1. 输入类型:明确输入参数包含一个基础URL字符串和一个包含键值对的对象。
  2. 转换逻辑:遍历对象的属性,将键和值转换为 key=value 的格式。
  3. 拼接方式:将转换后的键值对用 & 符号连接,并使用 ? 追加到基础URL后面。
  4. 编码处理:必须对值进行URL编码(例如使用 encodeURIComponentURLSearchParams),确保特殊字符不会破坏URL结构。
  5. 实现方式:优先使用现成的方法(如 URLSearchParams),如果需要兼容性则提供手动遍历的实现。

Anti-Patterns

  • 不要直接将对象转换为字符串拼接,必须进行键值对解析。
  • 不要忽略对特殊字符的编码。

Examples

输入:baseURL = "https://www.example.com", params = {query: 1, type: "search"} 输出:"https://www.example.com?query=1&type=search"

Triggers

  • js对象转url参数
  • 把对象拼接到url
  • javascript url query string
  • 对象转key=value

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.