| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | * |
| 7 | * @flow |
| 8 | */ |
| 9 | |
| 10 | export opaque type CrossOriginString: string = string; |
| 11 | |
| 12 | export function getCrossOriginString(input: ?string): ?CrossOriginString { |
| 13 | if (typeof input === 'string') { |
| 14 | return input === 'use-credentials' ? input : ''; |
| 15 | } |
| 16 | return undefined; |
| 17 | } |
| 18 | |
| 19 | export function getCrossOriginStringAs( |
| 20 | as: ?string, |
| 21 | input: ?string, |
| 22 | ): ?CrossOriginString { |
| 23 | if (as === 'font') { |
| 24 | return ''; |
| 25 | } |
| 26 | if (typeof input === 'string') { |
| 27 | return input === 'use-credentials' ? input : ''; |
| 28 | } |
| 29 | return undefined; |
| 30 | } |