Conversation
Co-authored-by: lslvxy <5688054+lslvxy@users.noreply.github.com> Agent-Logs-Url: https://github.com/lslvxy/insomnia/sessions/81c02a07-3298-4663-849b-d4505deb4a52
Co-authored-by: lslvxy <5688054+lslvxy@users.noreply.github.com> Agent-Logs-Url: https://github.com/lslvxy/insomnia/sessions/81c02a07-3298-4663-849b-d4505deb4a52
|
|
|
|
There was a problem hiding this comment.
Pull request overview
Fixes Url.getHost(), getPath(), and getRemote() returning empty strings when Url parsing is intentionally skipped for templated URLs (e.g. Nunjucks {{ }} / {% %}), by adding regex-based fallbacks that extract host/path/remote from this.origin.
Changes:
- Add module-level regex constants and fallback parsing in
getHost(),getPath(), andgetRemote()whenurlObjectis undefined. - Add tests covering templated host, templated path, host+port, block tags, and no-path URLs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/insomnia-scripting-environment/src/objects/urls.ts | Adds regex fallbacks to extract host/path/remote directly from the original string when native URL parsing is skipped. |
| packages/insomnia-scripting-environment/src/objects/tests/urls.test.ts | Adds unit tests validating fallback behavior for common templated URL shapes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/insomnia-scripting-environment/src/objects/__tests__/urls.test.ts
Show resolved
Hide resolved
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…urls.test.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot open a new pull request to apply changes based on the comments in this thread |
When a
Urlis constructed from a string containing Nunjucks template tags ({{ }}/{% %}),urlObjectis intentionally leftundefinedto avoid the native URL parser percent-encoding the tags. This causedgetHost(),getPath(), andgetRemote()to always return''for any templated URL.Changes
urls.ts— Added regex fallbacks ingetHost(),getPath(), andgetRemote()that extract the relevant segment directly fromthis.originwhenthis.urlObjectisundefined. Patterns extracted into three named module-level constants for clarity:Example — previously all three returned
'':urls.test.ts— New test covering host-only tags, path tags, host+port tags, Nunjucks block tags ({% %}), and no-path URLs.Link Issue #9746