UNPKG

service-model

Version:

An object oriented web service framework inspired by Windows Communication Foundation.

39 lines (38 loc) 1.4 kB
var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var messageFilter_1 = require("./messageFilter"); /** * A message filter that filters message where the url pathname match a given regular expression. * * <uml> * hide members * hide circle * MessageFilter <|-- RegExpAddressMessageFilter * </uml> */ var RegExpAddressMessageFilter = (function (_super) { __extends(RegExpAddressMessageFilter, _super); /** * Constructs a message filter. * @param pattern The regular expression that is required to match the url pathname. */ function RegExpAddressMessageFilter(pattern) { _super.call(this); if (!pattern) { throw new Error("Missing required argument 'pattern'."); } this._pattern = pattern; } /** * Tests whether or not the message satisfies the criteria of the filter. * @param message The message to match. */ RegExpAddressMessageFilter.prototype.match = function (message) { return this._pattern.test(message.url.pathname); }; return RegExpAddressMessageFilter; })(messageFilter_1.MessageFilter); exports.RegExpAddressMessageFilter = RegExpAddressMessageFilter;