Skip to content

✨ feat(mq-lang): add base64url/base64urld builtins and tests#1297

Merged
harehare merged 1 commit intomainfrom
feat/base64url-builtin
Feb 18, 2026
Merged

✨ feat(mq-lang): add base64url/base64urld builtins and tests#1297
harehare merged 1 commit intomainfrom
feat/base64url-builtin

Conversation

@harehare
Copy link
Copy Markdown
Owner

  • Add BASE64URL and BASE64URLD built-in functions for URL-safe base64 encode/decode
  • Add tests for base64url/base64urld
  • Update function docs and dispatch tables

Closes #1294
Closes #1295

- Add BASE64URL and BASE64URLD built-in functions for URL-safe base64 encode/decode
- Add tests for base64url/base64urld
- Update function docs and dispatch tables

Closes #1294
Closes #1295
Copilot AI review requested due to automatic review settings February 18, 2026 12:55
Copy link
Copy Markdown
Contributor

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 URL-safe base64 encoding and decoding functions (base64url and base64urld) to the mq language, addressing issues #1294 and #1295. The implementation follows the same pattern as the existing standard base64 functions (base64 and base64d), using the BASE64_URL_SAFE_NO_PAD encoder from the base64 crate instead of BASE64_STANDARD.

Changes:

  • Add BASE64URL and BASE64URLD builtin function implementations with support for String and Markdown types
  • Register hash constants, dispatch table entries, and function documentation for both new functions
  • Add test cases for encoding, decoding, and error handling with invalid types

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/mq-lang/src/eval/builtin.rs Adds BASE64URL and BASE64URLD builtin definitions, helper functions, hash constants, dispatch entries, and documentation
crates/mq-lang/src/eval.rs Adds test cases for base64url encode/decode and error handling

Comment on lines +2799 to +2830
#[case::base64url_encode(
vec![RuntimeValue::String("hello".into())],
vec![
ast_call("base64url", smallvec![
])
],
Ok(vec![RuntimeValue::String("aGVsbG8".into())])
)]
#[case::base64url_decode(
vec![RuntimeValue::String("aGVsbG8".into())],
vec![
ast_call("base64urld", smallvec![
])
],
Ok(vec![RuntimeValue::String("hello".into())])
)]
#[case::base64url(vec![RuntimeValue::Number(1.into())],
vec![
ast_call("base64url", smallvec![
])
],
Err(InnerError::Runtime(RuntimeError::InvalidTypes{token: Token { range: Range::default(), kind: TokenKind::Eof, module_id: 1.into()},
name: "base64url".to_string(),
args: vec![1.to_string().into()]})))]
#[case::base64urld(vec![RuntimeValue::Number(1.into())],
vec![
ast_call("base64urld", smallvec![
])
],
Err(InnerError::Runtime(RuntimeError::InvalidTypes{token: Token { range: Range::default(), kind: TokenKind::Eof, module_id: 1.into()},
name: "base64urld".to_string(),
args: vec![1.to_string().into()]})))]
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

The test coverage for base64url and base64urld is incomplete. The existing base64 and base64d tests include cases for Markdown nodes (see lines 2766-2770 and 2785-2790), but the new base64url and base64urld tests only cover String and Number types. To maintain consistency and ensure complete test coverage, add test cases for base64url and base64urld with Markdown nodes as input.

Copilot uses AI. Check for mistakes.
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Feb 18, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks


Comparing feat/base64url-builtin (6c7d923) with main (311be27)

Open in CodSpeed

@harehare harehare merged commit b2d1332 into main Feb 18, 2026
13 checks passed
@harehare harehare deleted the feat/base64url-builtin branch February 18, 2026 13:33
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.

Add base64urld function Add base64url function

2 participants