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S,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,CAAC;IACH,gBAAC;AAAD,CAAC,AAnJD,IAmJC;AAnJY,8BAAS",
10 "sourcesContent": [
11 "import { Disposable } from '../interface';\nimport { UIRouter } from '../router';\nimport { ParamTypeDefinition, ParamTypes } from '../params';\nimport { isDefined, isString } from '../common';\n\n/**\n * An API to customize the URL behavior and retrieve URL configuration\n *\n * This API is used to customize the behavior of the URL.\n * This includes optional trailing slashes ([[strictMode]]), case sensitivity ([[caseInsensitive]]),\n * and custom parameter encoding (custom [[type]]).\n *\n * It also has information about the location (url) configuration such as [[port]] and [[baseHref]].\n * This information can be used to build absolute URLs, such as\n * `https://example.com:443/basepath/state/substate?param1=a#hashvalue`;\n *\n * This API is found at `router.urlService.config` (see: [[UIRouter.urlService]], [[URLService.config]])\n */\nexport class UrlConfig implements Disposable {\n /** @internal */ paramTypes = new ParamTypes();\n /** @internal */ _decodeParams = true;\n /** @internal */ _isCaseInsensitive = false;\n /** @internal */ _isStrictMode = true;\n /** @internal */ _defaultSquashPolicy: boolean | string = false;\n\n /** @internal */ constructor(/** @internal */ private router: UIRouter) {}\n /** @internal */ public dispose = () => this.paramTypes.dispose();\n\n // Delegate these calls to the current LocationConfig implementation\n\n /**\n * Gets the base Href, e.g., `http://localhost/approot/`\n *\n * @return the application's base href\n */\n public baseHref = (): string => this.router.locationConfig.baseHref();\n\n /**\n * Gets or sets the hashPrefix\n *\n * This only applies when not running in [[html5Mode]] (pushstate mode)\n *\n * If the current url is `http://localhost/app#!/uirouter/path/#anchor`, it returns `!` which is the prefix for the \"hashbang\" portion.\n *\n * @return the hash prefix\n */\n\n public hashPrefix = (newprefix?: string): string => this.router.locationConfig.hashPrefix(newprefix);\n /**\n * Gets the host, e.g., `localhost`\n *\n * @return the protocol\n */\n public host = (): string => this.router.locationConfig.host();\n\n /**\n * Returns true when running in pushstate mode\n *\n * @return true when running in html5 mode (pushstate mode).\n */\n public html5Mode = (): boolean => this.router.locationConfig.html5Mode();\n\n /**\n * Gets the port, e.g., `80`\n *\n * @return the port number\n */\n public port = (): number => this.router.locationConfig.port();\n\n /**\n * Gets the protocol, e.g., `http`\n *\n * @return the protocol\n */\n public protocol = (): string => this.router.locationConfig.protocol();\n\n /**\n * Defines whether URL matching should be case sensitive (the default behavior), or not.\n *\n * #### Example:\n * ```js\n * // Allow case insensitive url matches\n * urlService.config.caseInsensitive(true);\n * ```\n *\n * @param value `false` to match URL in a case sensitive manner; otherwise `true`;\n * @returns the current value of caseInsensitive\n */\n public caseInsensitive(value?: boolean): boolean {\n return (this._isCaseInsensitive = isDefined(value) ? value : this._isCaseInsensitive);\n }\n\n /**\n * Sets the default behavior when generating or matching URLs with default parameter values.\n *\n * #### Example:\n * ```js\n * // Remove default parameter values from the url\n * urlService.config.defaultSquashPolicy(true);\n * ```\n *\n * @param value A string that defines the default parameter URL squashing behavior.\n * - `nosquash`: When generating an href with a default parameter value, do not squash the parameter value from the URL\n * - `slash`: When generating an href with a default parameter value, squash (remove) the parameter value, and, if the\n * parameter is surrounded by slashes, squash (remove) one slash from the URL\n * - any other string, e.g. \"~\": When generating an href with a default parameter value, squash (remove)\n * the parameter value from the URL and replace it with this string.\n * @returns the current value of defaultSquashPolicy\n */\n public defaultSquashPolicy(value?: boolean | string) {\n if (isDefined(value) && value !== true && value !== false && !isString(value))\n throw new Error(`Invalid squash policy: ${value}. Valid policies: false, true, arbitrary-string`);\n return (this._defaultSquashPolicy = isDefined(value) ? value : this._defaultSquashPolicy);\n }\n\n /**\n * Defines whether URLs should match trailing slashes, or not (the default behavior).\n *\n * #### Example:\n * ```js\n * // Allow optional trailing slashes\n * urlService.config.strictMode(false);\n * ```\n *\n * @param value `false` to match trailing slashes in URLs, otherwise `true`.\n * @returns the current value of strictMode\n */\n public strictMode(value?: boolean): boolean {\n return (this._isStrictMode = isDefined(value) ? value : this._isStrictMode);\n }\n\n /**\n * Creates and registers a custom [[ParamType]] object\n *\n * A custom parameter type can be used to generate URLs with typed parameters or custom encoding/decoding.\n *\n * #### Note: Register custom types *before using them* in a state definition.\n *\n * #### Example:\n * ```js\n * // Encode object parameter as JSON string\n * urlService.config.type('myjson', {\n * encode: (obj) => JSON.stringify(obj),\n * decode: (str) => JSON.parse(str),\n * is: (val) => typeof(val) === 'object',\n * pattern: /[^/]+/,\n * equals: (a, b) => _.isEqual(a, b),\n * });\n * ```\n *\n * See [[ParamTypeDefinition]] for more examples\n *\n * @param name The type name.\n * @param definition The type definition. See [[ParamTypeDefinition]] for information on the values accepted.\n * @param definitionFn A function that is injected before the app runtime starts.\n * The result of this function should be a [[ParamTypeDefinition]].\n * The result is merged into the existing `definition`.\n * See [[ParamType]] for information on the values accepted.\n *\n * @returns if only the `name` parameter was specified: the currently registered [[ParamType]] object, or undefined\n */\n type(name: string, definition?: ParamTypeDefinition, definitionFn?: () => ParamTypeDefinition) {\n const type = this.paramTypes.type(name, definition, definitionFn);\n return !isDefined(definition) ? type : this;\n }\n}\n"
12 ]
13}
\No newline at end of file