Skip to content

Instantly share code, notes, and snippets.

View FredricW's full-sized avatar

Hans Fredric Waadeland FredricW

View GitHub Profile
@FredricW
FredricW / GetColonKeysFromUrlPath.ts
Last active October 31, 2022 08:06
Parse url path into Typescript types
/**
* Extracts url wildcards formatted as a string beginning with colon.
* ```
* 'user/:userId/profile' -> 'userId'
* ```
*
* Multiple instances yields a union type:
* ```
* 'user/:userId/contacts/:listId' -> 'userId' | 'listId'
* ```