collectype / factory/urls/urlPathname / urlPathnameFactory
urlPathnameFactory<
T,C>(ctx,oper): <K>(field,target) =>C
Defined in: factory/urls/urlPathname.ts:34
Creates a predicate filter for URL pathname comparison using PredicType.url.pathname.
T
The item type in the collection.
C extends Wherable<T, C>
The Wherable context type (must extend Wherable<T, C>).
C
The context (usually a collection) supporting the where method.
UrlPathnameOper
The URL pathname operation to perform.
Returns a function that takes a URL field on T, compares its pathname, and filters the context.
<K>(field, target) => C
// Example based on sample/models/Person and sample/data/person
import { BaseFunctions, urlPathnameFactory } from 'collectype';
import { Person } from '../../../sample/models/Person';
import { people } from '../../../sample/data/person';
class PersonFunctions extends BaseFunctions<Person> {
urlPathnameIncludes = urlPathnameFactory<Person, this>(this, 'includes');
}
const fn = new PersonFunctions(people);
const filtered = fn.urlPathnameIncludes('website', '/people/');
// filtered contains people whose website pathname includes the expected segment
URL are supported.PredicType.url.pathname.