Differentiating Between Branded Strings in a Union

How would I differentiate between a union of two branded strings?
export const UrlPath = Schema.String.pipe(
  Schema.filter((s) => Url.fromString(s).pipe(Either.isRight)),
  Schema.brand("RemoteUrl"),
);
export const FilePath = Schema.String.pipe(
  Schema.filter((s) => s.startsWith("file:///")),
  Schema.brand("FilePath"),
);
export const Path = Schema.Union(UrlPath, FilePath);

Originally I thought there might be a Brand.is() function, but that doesn't exist and I don't think that would actually work. What would you recommend to do instead? I want to perform one action if it's a FilePath and another if it's a RemoteUrl
Was this page helpful?