Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

RFC 001: Path Matching/Resolution Strategy #120

@Tiberriver256

Description

@Tiberriver256

The original implementation of Polaris was that the path requested by the client had to equal the path declared by the New-PolarisRoute function.

The current implementation takes a matching approach. If the path declared by New-PolarisRoute matches the beginning of the requested path the ScriptBlock will execute.

The current implementation of a more flexible path matching strategy allows for scenarios like the built-in file browser where the remainder of the URL can be assumed to be a relative path to the local file but it can be argued that it is too flexible as URLs that are technically "wrong" will match and the ScriptBlock may execute, as mentioned in #116.

We would like to ask for input from the community on a proposed solution currently in Pull Request #119. The proposal is to match the path strategy of Express.js.

This means we would support RegularExpressions for paths and named parameters within the path:

Example paths:

  1. /hello - Would get converted to the following regular expression: ^/hello$. This would guarantee hello would be the only match and return to the original implementation.
  2. /hello.* - Would get converted to the following regular expression: ^/hello.*$. This would match the current implementation and allow for any all requests that begin with hello to trigger the desired scriptlbock
  3. /hello/:firstname/:lastname - Would get converted to the following regular expression: ^/hello/(?<firstname>.*)/(?<lastname>.*). The $Matches from the regular expression would then be converted to a PSCustomObject and be made available within the ScriptBlock as something like $Request.Parameters

As this is a breaking change we would love feedback and additional suggestions on the implementation. Thanks @TimCurwick for the feedback on the PR to bring this out for a more open discussion.

*EDIT:
This would introduce the following breaking change. The below request URL would match in the current implementation and would no longer match in the new implementation.

Route path: /flights
Request URL: http://localhost:3000/flights/myspecialflight

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions