Skip to content

Commit

Permalink
Merge pull request #397 from salesforce/v5-docs-permutepath
Browse files Browse the repository at this point in the history
V5 Docs - `permutePath`
  • Loading branch information
colincasey authored Apr 12, 2024
2 parents ac1a471 + 827538a commit ee9d4ff
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
1 change: 1 addition & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ docs/*.md

# subsequent PRs will un-ignore areas that are under review until
# all docs are complete and we can drop this ignore file entirely
!docs/tough-cookie.permutepath.md
!docs/tough-cookie.version.md
!docs/tough-cookie.parsedate.md
!docs/tough-cookie.formatdate.md
Expand Down
61 changes: 61 additions & 0 deletions api/docs/tough-cookie.permutepath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [permutePath](./tough-cookie.permutepath.md)

## permutePath() function

Generates the permutation of all possible values that [pathMatch()](./tough-cookie.pathmatch.md) the `path` parameter. The array is in longest-to-shortest order. Useful when building custom [Store](./tough-cookie.store.md) implementations.

**Signature:**

```typescript
export declare function permutePath(path: string): string[];
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

path


</td><td>

string


</td><td>

the path to generate permutations for


</td></tr>
</tbody></table>
**Returns:**

string\[\]

## Example


```
permutePath('/foo/bar/')
// ['/foo/bar/', '/foo/bar', '/foo', '/']
```

13 changes: 11 additions & 2 deletions lib/cookie/permutePath.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import * as validators from '../validators'

/**
* Gives the permutation of all possible `pathMatch`es of a given path. The
* array is in longest-to-shortest order. Handy for indexing.
* Generates the permutation of all possible values that {@link pathMatch} the `path` parameter.
* The array is in longest-to-shortest order. Useful when building custom {@link Store} implementations.
*
* @example
* ```
* permutePath('/foo/bar/')
* // ['/foo/bar/', '/foo/bar', '/foo', '/']
* ```
*
* @param path - the path to generate permutations for
* @public
*/
export function permutePath(path: string): string[] {
validators.validate(validators.isString(path))
Expand Down

0 comments on commit ee9d4ff

Please sign in to comment.