Skip to content

Conversation

Copy link

Copilot AI commented Nov 11, 2025

Add tests for unicode character handling

This PR adds comprehensive tests to validate unicode character handling (e.g., 🚀) in the fast-url library.

Tasks:

  • Explore repository structure and understand existing tests
  • Run existing tests to establish baseline (153 tests passing)
  • Understand how unicode is handled in the codebase (via codePointAt in querystring)
  • Add unicode tests for createUrl function (path and query params) - 6 tests
  • Add unicode tests for query function - 5 tests
  • Add unicode tests for subst function - 4 tests
  • Add Vietnamese character tests - 7 tests (3 for createUrl, 2 for query, 2 for subst)
  • Run tests to validate all changes (175 tests passing, +22 new tests)
  • Format code with biome
  • Run CodeQL security scan (0 alerts)

Summary:

Added 22 new tests covering:

  • Emoji characters (🚀, 🌟) in path and query parameters
  • Unicode accents (é)
  • CJK characters (中文)
  • Unicode symbols (✓)
  • Vietnamese characters (Việt Nam, Đà Nẵng, Sài Gòn, Nguyễn, Trần)
  • Mixed unicode and ASCII strings
  • Multiple unicode characters in single URLs

Vietnamese Test Coverage:

  1. createUrl function (3 tests):

    • Vietnamese city names in path parameters (Đà Nẵng)
    • Vietnamese text in query parameters (Việt Nam, Sài Gòn)
    • Vietnamese names with path and query together (Nguyễn, Trần)
  2. query function (2 tests):

    • Vietnamese location names (Việt Nam, Đà Nẵng)
    • Vietnamese names with tone marks (Nguyễn, Trần)
  3. subst function (2 tests):

    • Vietnamese location names in substitution
    • Vietnamese names with diacritics

All tests validate proper URL encoding of unicode characters using the existing encodeURIComponent and codePointAt implementation.

Security Summary:

CodeQL security scan completed with 0 alerts. No security vulnerabilities detected.

Original prompt

Add tests that handle unicode chars, such as 🚀


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add tests that handle unicode characters Add unicode character test coverage Nov 11, 2025
Copilot AI requested a review from hckhanh November 11, 2025 15:47
Copilot finished work on behalf of hckhanh November 11, 2025 15:47
@hckhanh hckhanh marked this pull request as ready for review November 11, 2025 15:50
Copilot AI review requested due to automatic review settings November 11, 2025 15:50
@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1d05c70) to head (264c2ef).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #80   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          191       191           
  Branches        63        63           
=========================================
  Hits           191       191           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hckhanh
Copy link
Owner

hckhanh commented Nov 11, 2025

@copilot add test with Vietnamese samples

Copilot finished reviewing on behalf of hckhanh November 11, 2025 15:53
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 11, 2025

CodSpeed Performance Report

Merging #80 will not alter performance

Comparing copilot/add-unicode-character-tests (264c2ef) with main (1d05c70)

Summary

✅ 157 untouched
⏩ 22 skipped1

Footnotes

  1. 22 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive test coverage for unicode character handling across the library's URL-building functions. The implementation uses codePointAt for unicode-aware encoding in query strings, while path parameters use the standard encodeURIComponent function.

  • Added 15 new test cases validating unicode encoding (emoji, accents, CJK characters, symbols)
  • Tests cover path parameters, query parameters, and template substitution
  • All tests verify correct UTF-8 percent-encoding (e.g., 🚀%F0%9F%9A%80)

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
test/urlcat.test.ts Adds 6 tests for createUrl validating unicode in path parameters, query parameters, and combined scenarios
test/subst.test.ts Adds 4 tests for subst validating unicode in template parameter substitution
test/query.test.ts Adds 5 tests for query validating unicode in both keys and values of query strings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link

Copy link
Author

Copilot AI commented Nov 11, 2025

@copilot add test with Vietnamese samples

Added 7 Vietnamese character tests covering:

  • City/country names: Việt Nam, Đà Nẵng, Sài Gòn
  • Common Vietnamese surnames: Nguyễn, Trần

Tests validate proper encoding of Vietnamese diacritics (â, ă, đ, ê, ô, ơ, ư) and tone marks in path parameters, query strings, and template substitution.

Commit: 264c2ef

@hckhanh hckhanh merged commit 6a497ac into main Nov 11, 2025
17 checks passed
@hckhanh hckhanh deleted the copilot/add-unicode-character-tests branch November 11, 2025 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants