Skip to content

Include %Port% token in default RDP templates (#203)#204

Open
CodyBatt wants to merge 1 commit into
masterfrom
fix/203-default-rdp-port-token
Open

Include %Port% token in default RDP templates (#203)#204
CodyBatt wants to merge 1 commit into
masterfrom
fix/203-default-rdp-port-token

Conversation

@CodyBatt

@CodyBatt CodyBatt commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Replace the hardcoded 'server port:i:3389' with 'server port:i:%Port%' in the default and example RDP templates. This allows SCALUS to connect using non-default RDP ports specified in the connection URI.

Also fix ParseTemplate to preserve values with multiple colons (so custom templates can use formats like %Host%:%Port% in full address if desired), and add a port default of 3389 when no port is specified in standard URIs.

Adds a test verifying that custom templates using %Host% (without port) in full address work correctly with server port handling the port separately.

Fixes #203

Replace the hardcoded 'server port:i:3389' with 'server port:i:%Port%'
in the default and example RDP templates. This allows SCALUS to connect
using non-default RDP ports specified in the connection URI.

Also fix ParseTemplate to preserve values with multiple colons (so
custom templates can use formats like %Host%:%Port% in full address if
desired), and add a port default of 3389 when no port is specified in
standard URIs.

Adds a test verifying that custom templates using %Host% (without port)
in full address work correctly with server port handling the port
separately.

Copilot AI left a comment

Copy link
Copy Markdown

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 enables SCALUS to generate RDP files that honor non-default RDP ports by replacing hardcoded server port:i:3389 with a %Port% token in the default and example templates. It also improves template parsing so values containing multiple colons are preserved (supporting patterns like %Host%:%Port%), and introduces logic intended to default the port to 3389 when not present in a “standard” URI parse.

Changes:

  • Update built-in and example .rdp templates to use server port:i:%Port% instead of a hardcoded 3389.
  • Fix ParseTemplate to preserve template values containing multiple : characters.
  • Add a test covering custom templates where the port is applied via server port only (not in full address).

Reviewed changes

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

Show a summary per file
File Description
test/TestDefaultRdpUrlParser.cs Adds coverage for custom templates that keep full address host-only while using server port for the port.
src/UrlParser/DefaultRdpUrlParser.cs Adds port-defaulting logic for non-RDP URI parsing and fixes template parsing for multi-colon values.
src/Resources/Default.rdp Switches default template to use %Port% for server port.
scripts/examples/WinRdpTemplate.rdp Updates example template to use %Port% for server port.
scripts/examples/RdpRemoteAppTemplate.rdp Updates example template to use %Port% for server port.
scripts/examples/exampleRdpTemplate.rdp Updates example template to use %Port% for server port.

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

Comment on lines +181 to +185
// Ensure port defaults to 3389 if not specified in the URL
if (!Dictionary.ContainsKey(Token.Port) || string.IsNullOrEmpty(Dictionary[Token.Port]))
{
Dictionary[Token.Port] = "3389";
}
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.

Using non-default port

2 participants