Skip to content
Back to skills

Javascript对象转Url查询参数

ASecurity

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

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
developmentjavascriptjava

Security analysis

A100/100

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill 'javascript对象转url查询参数' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Javascript对象转Url查询参数?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Javascript对象转Url查询参数
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-javascript-url/badge)](https://www.skillsdirectory.com/skills/david-li0406-javascript-url)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "0aa62173-f063-4d58-80f3-961d8faa30cd"
name: "JavaScript对象转URL查询参数"
description: "将JavaScript对象转换为URL查询字符串(key=value格式)并拼接到基础URL中。"
version: "0.1.0"
tags:
  - "JavaScript"
  - "URL"
  - "查询参数"
  - "对象转换"
triggers:
  - "js对象转url参数"
  - "把对象拼接到url"
  - "javascript url query string"
  - "对象转key=value"
---

# 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编码(例如使用 `encodeURIComponent` 或 `URLSearchParams`),确保特殊字符不会破坏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

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…