@angular-wave/angular.ts 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/index.d.ts +1 -84
- package/{src/index.ts → @types/namespace.d.ts} +4 -24
- package/@types/router/template-factory.d.ts +2 -2
- package/dist/angular-ts.esm.js +3 -3
- package/dist/angular-ts.umd.js +3 -3
- package/dist/angular-ts.umd.min.js +1 -1
- package/package.json +8 -1
- package/.github/workflows/ci.yml +0 -104
- package/.github/workflows/gh-pages.yml +0 -75
- package/.husky/pre-commit +0 -5
- package/.prettierignore +0 -9
- package/CHANGELOG.md +0 -17667
- package/CODE_OF_CONDUCT.md +0 -3
- package/CONTRIBUTING.md +0 -247
- package/DEVELOPERS.md +0 -499
- package/Makefile +0 -60
- package/RELEASE.md +0 -86
- package/TRIAGING.md +0 -127
- package/docs/.cspell.yml +0 -8
- package/docs/.github/dependabot.yml +0 -14
- package/docs/.nvmrc +0 -1
- package/docs/CONTRIBUTING.md +0 -28
- package/docs/Dockerfile +0 -4
- package/docs/LICENSE +0 -201
- package/docs/README.md +0 -217
- package/docs/assets/icons/logo.svg +0 -1
- package/docs/assets/scss/_variables_project.scss +0 -12
- package/docs/assets/scss/_variables_project_after_bs.scss +0 -8
- package/docs/assets/scss/index.scss +0 -48
- package/docs/config.yaml +0 -15
- package/docs/content/_index.md +0 -28
- package/docs/content/docs/_index.md +0 -61
- package/docs/content/docs/directive/_index.md +0 -4
- package/docs/content/docs/directive/app.md +0 -11
- package/docs/content/docs/directive/aria.md +0 -0
- package/docs/content/docs/directive/bind.md +0 -72
- package/docs/content/docs/directive/blur.md +0 -38
- package/docs/content/docs/directive/channel.md +0 -37
- package/docs/content/docs/directive/class-even.md +0 -47
- package/docs/content/docs/directive/class-odd.md +0 -48
- package/docs/content/docs/directive/class.md +0 -64
- package/docs/content/docs/directive/click.md +0 -41
- package/docs/content/docs/directive/cloak.md +0 -74
- package/docs/content/docs/directive/copy.md +0 -38
- package/docs/content/docs/directive/cut.md +0 -40
- package/docs/content/docs/directive/dblclick.md +0 -41
- package/docs/content/docs/directive/focus.md +0 -38
- package/docs/content/docs/directive/get.md +0 -203
- package/docs/content/docs/directive/include.md +0 -7
- package/docs/content/docs/directive/keydown.md +0 -38
- package/docs/content/docs/directive/keyup.md +0 -38
- package/docs/content/docs/directive/load.md +0 -43
- package/docs/content/docs/directive/mousedown.md +0 -38
- package/docs/content/docs/directive/mouseenter.md +0 -38
- package/docs/content/docs/directive/mouseleave.md +0 -38
- package/docs/content/docs/directive/mousemove.md +0 -38
- package/docs/content/docs/directive/mouseout.md +0 -38
- package/docs/content/docs/directive/mouseover.md +0 -38
- package/docs/content/docs/directive/mouseup.md +0 -38
- package/docs/content/docs/directive/non-bindable.md +0 -28
- package/docs/content/docs/filter/_index.md +0 -4
- package/docs/content/docs/filter/filter.md +0 -78
- package/docs/content/docs/filter/json.md +0 -19
- package/docs/content/docs/filter/limit-to.md +0 -30
- package/docs/content/docs/filter/order-by.md +0 -123
- package/docs/content/docs/provider/_index.md +0 -4
- package/docs/content/docs/provider/eventBusProvider.md +0 -35
- package/docs/content/docs/provider/locationProvider.md +0 -26
- package/docs/content/docs/provider/logProvider.md +0 -59
- package/docs/content/docs/provider/sceProvider.md +0 -194
- package/docs/content/docs/provider/templateCacheProvider.md +0 -100
- package/docs/content/docs/provider/templateRequestProvider.md +0 -5
- package/docs/content/docs/service/_index.md +0 -4
- package/docs/content/docs/service/compile.md +0 -5
- package/docs/content/docs/service/controller.md +0 -5
- package/docs/content/docs/service/eventBus.md +0 -56
- package/docs/content/docs/service/http.md +0 -161
- package/docs/content/docs/service/interpolation.md +0 -5
- package/docs/content/docs/service/location.md +0 -57
- package/docs/content/docs/service/log.md +0 -113
- package/docs/content/docs/service/parse.md +0 -5
- package/docs/content/docs/service/rootElement.md +0 -5
- package/docs/content/docs/service/rootScope.md +0 -5
- package/docs/content/docs/service/sce.md +0 -194
- package/docs/content/docs/service/templateCache.md +0 -64
- package/docs/content/docs/service/templateRequest.md +0 -5
- package/docs/content/docs/service/url.md +0 -5
- package/docs/content/docs/values/_index.md +0 -4
- package/docs/content/docs/values/document.md +0 -29
- package/docs/content/docs/values/window.md +0 -29
- package/docs/docker-compose.yaml +0 -12
- package/docs/docsy.work +0 -5
- package/docs/docsy.work.sum +0 -0
- package/docs/go.mod +0 -5
- package/docs/go.sum +0 -6
- package/docs/hugo-disabled.toml +0 -220
- package/docs/hugo.yaml +0 -200
- package/docs/layouts/404.html +0 -13
- package/docs/layouts/_markup/render-heading.html +0 -1
- package/docs/layouts/partials/hooks/head-end.html +0 -3
- package/docs/layouts/shortcodes/showcss.html +0 -2
- package/docs/layouts/shortcodes/showhtml.html +0 -2
- package/docs/layouts/shortcodes/showjs.html +0 -2
- package/docs/layouts/shortcodes/showraw.html +0 -1
- package/docs/layouts/shortcodes/version.html +0 -1
- package/docs/package-lock.json +0 -2293
- package/docs/package.json +0 -53
- package/docs/static/examples/counter/counter-test.html +0 -13
- package/docs/static/examples/counter/counter.html +0 -5
- package/docs/static/examples/counter/counter.test.js +0 -28
- package/docs/static/examples/document/document.html +0 -3
- package/docs/static/examples/eventbus/eventbus-test.html +0 -15
- package/docs/static/examples/eventbus/eventbus.html +0 -13
- package/docs/static/examples/eventbus/eventbus.js +0 -15
- package/docs/static/examples/eventbus/eventbus.test.js +0 -19
- package/docs/static/examples/i18n/i18n.html +0 -77
- package/docs/static/examples/ng-bind/ng-bind.html +0 -9
- package/docs/static/examples/ng-blur/ng-blur.html +0 -9
- package/docs/static/examples/ng-channel/ng-channel-test.html +0 -17
- package/docs/static/examples/ng-channel/ng-channel.html +0 -24
- package/docs/static/examples/ng-channel/ng-channel.test.js +0 -31
- package/docs/static/examples/ng-class/ng-class.html +0 -71
- package/docs/static/examples/ng-class-even/ng-class-even.html +0 -8
- package/docs/static/examples/ng-class-odd/ng-class-odd.html +0 -8
- package/docs/static/examples/ng-click/ng-click.html +0 -6
- package/docs/static/examples/ng-copy/ng-copy.html +0 -6
- package/docs/static/examples/ng-cut/ng-cut.html +0 -6
- package/docs/static/examples/ng-dblclick/ng-dblclick.html +0 -10
- package/docs/static/examples/ng-focus/ng-focus.html +0 -9
- package/docs/static/examples/ng-keydown/ng-keydown.html +0 -9
- package/docs/static/examples/ng-keyup/ng-keyup.html +0 -9
- package/docs/static/examples/ng-load/ng-load.html +0 -8
- package/docs/static/examples/ng-mousedown/ng-mousedown.html +0 -6
- package/docs/static/examples/ng-mouseenter/ng-mouseenter.html +0 -4
- package/docs/static/examples/ng-mouseleave/ng-mouseleave.html +0 -4
- package/docs/static/examples/ng-mousemove/ng-mousemove.html +0 -4
- package/docs/static/examples/ng-mouseout/ng-mouseout.html +0 -4
- package/docs/static/examples/ng-mouseover/ng-mouseover.html +0 -4
- package/docs/static/examples/ng-mouseup/ng-mouseup.html +0 -4
- package/docs/static/examples/ng-non-bindable/ng-non-bindable-test.html +0 -13
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.html +0 -3
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.test.js +0 -11
- package/docs/static/examples/window/window.html +0 -4
- package/docs/static/typedoc/.nojekyll +0 -1
- package/docs/static/typedoc/assets/hierarchy.js +0 -1
- package/docs/static/typedoc/assets/highlight.css +0 -29
- package/docs/static/typedoc/assets/icons.js +0 -18
- package/docs/static/typedoc/assets/icons.svg +0 -1
- package/docs/static/typedoc/assets/main.js +0 -60
- package/docs/static/typedoc/assets/navigation.js +0 -1
- package/docs/static/typedoc/assets/search.js +0 -1
- package/docs/static/typedoc/assets/style.css +0 -1633
- package/docs/static/typedoc/classes/Location.html +0 -55
- package/docs/static/typedoc/classes/LocationProvider.html +0 -20
- package/docs/static/typedoc/classes/LogProvider.html +0 -6
- package/docs/static/typedoc/classes/PubSub.html +0 -71
- package/docs/static/typedoc/classes/PubSubProvider.html +0 -4
- package/docs/static/typedoc/classes/TemplateCacheProvider.html +0 -5
- package/docs/static/typedoc/hierarchy.html +0 -1
- package/docs/static/typedoc/index.html +0 -1
- package/docs/static/typedoc/interfaces/DefaultPorts.html +0 -5
- package/docs/static/typedoc/interfaces/Html5Mode.html +0 -23
- package/docs/static/typedoc/interfaces/HttpHeadersGetter.html +0 -1
- package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +0 -31
- package/docs/static/typedoc/interfaces/HttpRequestConfigHeaders.html +0 -6
- package/docs/static/typedoc/interfaces/HttpRequestTransformer.html +0 -1
- package/docs/static/typedoc/interfaces/HttpResponse.html +0 -7
- package/docs/static/typedoc/interfaces/HttpResponseTransformer.html +0 -1
- package/docs/static/typedoc/interfaces/HttpService.html +0 -38
- package/docs/static/typedoc/interfaces/LogService.html +0 -12
- package/docs/static/typedoc/interfaces/RequestConfig.html +0 -48
- package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +0 -38
- package/docs/static/typedoc/interfaces/ServiceProvider.html +0 -5
- package/docs/static/typedoc/interfaces/UrlParts.html +0 -9
- package/docs/static/typedoc/types/HttpParamSerializer.html +0 -2
- package/docs/static/typedoc/types/HttpParams.html +0 -2
- package/docs/static/typedoc/types/HttpPromise.html +0 -1
- package/docs/static/typedoc/types/HttpResponseStatus.html +0 -1
- package/docs/static/typedoc/types/LogCall.html +0 -2
- package/docs/static/typedoc/types/LogServiceFactory.html +0 -2
- package/docs/static/typedoc/types/UrlChangeListener.html +0 -5
- package/docs/static/typedoc/variables/EventBus.html +0 -1
- package/docs/static/version.js +0 -13
- package/docs/test-results/.last-run.json +0 -4
- package/docs/test-results/static-examples-counter-counter-counter-example/error-context.md +0 -50
- package/eslint.config.js +0 -26
- package/images/android-chrome-192x192.png +0 -0
- package/images/android-chrome-512x512.png +0 -0
- package/images/apple-touch-icon.png +0 -0
- package/images/favicon-16x16.png +0 -0
- package/images/favicon-32x32.png +0 -0
- package/images/favicon.ico +0 -0
- package/images/site.webmanifest +0 -19
- package/index.html +0 -86
- package/legacy.d.ts +0 -1678
- package/playwright.config.ts +0 -81
- package/public/jasmine/boot0.js +0 -66
- package/public/jasmine/boot1.js +0 -134
- package/public/jasmine/jasmine-html.js +0 -970
- package/public/jasmine/jasmine.css +0 -323
- package/public/jasmine/jasmine.js +0 -11406
- package/public/public/README.md +0 -1
- package/public/public/circle.html +0 -1
- package/public/public/jasmine-helper.css +0 -9
- package/public/public/my_child_directive.html +0 -1
- package/public/public/my_directive.html +0 -1
- package/public/public/my_other_directive.html +0 -1
- package/public/public/test.html +0 -1
- package/rollup.config.js +0 -51
- package/src/angular.js +0 -286
- package/src/angular.spec.js +0 -1191
- package/src/animations/animate-cache.js +0 -80
- package/src/animations/animate-children-directive.js +0 -32
- package/src/animations/animate-children-directive.md +0 -80
- package/src/animations/animate-css-driver.js +0 -284
- package/src/animations/animate-css.html +0 -58
- package/src/animations/animate-css.js +0 -915
- package/src/animations/animate-css.md +0 -263
- package/src/animations/animate-js-driver.js +0 -60
- package/src/animations/animate-js.html +0 -47
- package/src/animations/animate-js.js +0 -371
- package/src/animations/animate-queue.js +0 -859
- package/src/animations/animate-runner.js +0 -193
- package/src/animations/animate-swap.js +0 -33
- package/src/animations/animate-swap.md +0 -88
- package/src/animations/animate.html +0 -19
- package/src/animations/animate.js +0 -546
- package/src/animations/animate.md +0 -933
- package/src/animations/animate.spec.js +0 -490
- package/src/animations/animation.js +0 -519
- package/src/animations/animations.test.js +0 -10
- package/src/animations/interface.ts +0 -19
- package/src/animations/raf-scheduler.html +0 -19
- package/src/animations/raf-scheduler.js +0 -92
- package/src/animations/raf-scheduler.spec.js +0 -98
- package/src/animations/shared.js +0 -341
- package/src/binding.html +0 -19
- package/src/binding.spec.js +0 -474
- package/src/binding.test.js +0 -10
- package/src/core/compile/attributes.js +0 -337
- package/src/core/compile/compile.html +0 -19
- package/src/core/compile/compile.js +0 -3271
- package/src/core/compile/compile.md +0 -1128
- package/src/core/compile/compile.spec.js +0 -15574
- package/src/core/compile/compile.test.js +0 -12
- package/src/core/controller/controller.html +0 -22
- package/src/core/controller/controller.js +0 -193
- package/src/core/controller/controller.spec.js +0 -334
- package/src/core/controller/controller.test.js +0 -12
- package/src/core/controller/interface.ts +0 -6
- package/src/core/core.html +0 -20
- package/src/core/core.test.js +0 -12
- package/src/core/di/injector.html +0 -19
- package/src/core/di/injector.js +0 -307
- package/src/core/di/injector.md +0 -740
- package/src/core/di/injector.spec.js +0 -2310
- package/src/core/di/injector.test.js +0 -12
- package/src/core/di/internal-injector.js +0 -286
- package/src/core/di/ng-module.html +0 -19
- package/src/core/di/ng-module.js +0 -229
- package/src/core/di/ng-module.spec.js +0 -263
- package/src/core/di/ng-module.test.js +0 -12
- package/src/core/filter/filter.html +0 -19
- package/src/core/filter/filter.js +0 -55
- package/src/core/filter/filter.md +0 -132
- package/src/core/filter/filter.spec.js +0 -149
- package/src/core/filter/filter.test.js +0 -12
- package/src/core/interpolate/interface.ts +0 -14
- package/src/core/interpolate/interpolate.html +0 -22
- package/src/core/interpolate/interpolate.js +0 -410
- package/src/core/interpolate/interpolate.spec.js +0 -601
- package/src/core/interpolate/interpolate.test.js +0 -12
- package/src/core/parse/ast/ast-node.ts +0 -81
- package/src/core/parse/ast/ast.html +0 -19
- package/src/core/parse/ast/ast.js +0 -574
- package/src/core/parse/ast/ast.spec.js +0 -1453
- package/src/core/parse/ast/ast.test.js +0 -10
- package/src/core/parse/ast-type.js +0 -23
- package/src/core/parse/interface.ts +0 -84
- package/src/core/parse/interpreter.js +0 -915
- package/src/core/parse/lexer/lexer.html +0 -19
- package/src/core/parse/lexer/lexer.js +0 -338
- package/src/core/parse/lexer/lexer.spec.js +0 -303
- package/src/core/parse/lexer/lexer.test.js +0 -10
- package/src/core/parse/lexer/token.ts +0 -22
- package/src/core/parse/parse.html +0 -19
- package/src/core/parse/parse.js +0 -337
- package/src/core/parse/parse.md +0 -57
- package/src/core/parse/parse.spec.js +0 -2107
- package/src/core/parse/parse.test.js +0 -10
- package/src/core/parse/parser/parser.html +0 -19
- package/src/core/parse/parser/parser.js +0 -64
- package/src/core/parse/parser/parser.spec.js +0 -8
- package/src/core/parse/parser/parser.test.js +0 -10
- package/src/core/prop.spec.js +0 -775
- package/src/core/root-element.spec.js +0 -14
- package/src/core/sanitize/interface.ts +0 -10
- package/src/core/sanitize/sanitize-uri.js +0 -75
- package/src/core/sanitize/sanitize-uri.spec.js +0 -249
- package/src/core/sanitize/sanitize-uri.test.js +0 -12
- package/src/core/sanitize/sanitize.html +0 -22
- package/src/core/scope/scope.html +0 -19
- package/src/core/scope/scope.js +0 -1252
- package/src/core/scope/scope.spec.js +0 -3000
- package/src/core/scope/scope.test.js +0 -12
- package/src/directive/aria/aria.html +0 -19
- package/src/directive/aria/aria.js +0 -382
- package/src/directive/aria/aria.md +0 -145
- package/src/directive/aria/aria.spec.js +0 -1241
- package/src/directive/aria/aria.test.js +0 -12
- package/src/directive/attrs/attrs.html +0 -19
- package/src/directive/attrs/attrs.js +0 -106
- package/src/directive/attrs/attrs.md +0 -224
- package/src/directive/attrs/attrs.spec.js +0 -71
- package/src/directive/attrs/attrs.test.js +0 -12
- package/src/directive/attrs/boolean.html +0 -19
- package/src/directive/attrs/boolean.spec.js +0 -137
- package/src/directive/attrs/boolean.test.js +0 -12
- package/src/directive/attrs/element-style.html +0 -22
- package/src/directive/attrs/element-style.spec.js +0 -85
- package/src/directive/attrs/element-style.test.js +0 -12
- package/src/directive/attrs/src.html +0 -19
- package/src/directive/attrs/src.spec.js +0 -163
- package/src/directive/attrs/src.test.js +0 -12
- package/src/directive/bind/bind-html.spec.js +0 -36
- package/src/directive/bind/bind.html +0 -20
- package/src/directive/bind/bind.js +0 -78
- package/src/directive/bind/bind.md +0 -142
- package/src/directive/bind/bind.spec.js +0 -314
- package/src/directive/bind/bind.test.js +0 -12
- package/src/directive/channel/channel.html +0 -19
- package/src/directive/channel/channel.js +0 -30
- package/src/directive/channel/channel.spec.js +0 -67
- package/src/directive/channel/channel.test.js +0 -10
- package/src/directive/class/class-test.html +0 -23
- package/src/directive/class/class.html +0 -19
- package/src/directive/class/class.js +0 -184
- package/src/directive/class/class.spec.js +0 -704
- package/src/directive/class/class.test.js +0 -12
- package/src/directive/cloak/cloak.html +0 -19
- package/src/directive/cloak/cloak.js +0 -11
- package/src/directive/cloak/cloak.spec.js +0 -44
- package/src/directive/cloak/cloak.test.js +0 -12
- package/src/directive/controller/controller.html +0 -22
- package/src/directive/controller/controller.js +0 -11
- package/src/directive/controller/controller.md +0 -46
- package/src/directive/controller/controller.spec.js +0 -175
- package/src/directive/controller/controller.test.js +0 -12
- package/src/directive/events/click.spec.js +0 -35
- package/src/directive/events/event.spec.js +0 -267
- package/src/directive/events/events-test.html +0 -36
- package/src/directive/events/events.html +0 -20
- package/src/directive/events/events.js +0 -65
- package/src/directive/events/events.md +0 -125
- package/src/directive/events/events.test.js +0 -12
- package/src/directive/form/form.html +0 -19
- package/src/directive/form/form.js +0 -669
- package/src/directive/form/form.spec.js +0 -1515
- package/src/directive/form/form.test.js +0 -12
- package/src/directive/http/delete.spec.js +0 -23
- package/src/directive/http/form-router-test.html +0 -44
- package/src/directive/http/form-test.html +0 -18
- package/src/directive/http/get.spec.js +0 -488
- package/src/directive/http/http.html +0 -22
- package/src/directive/http/http.js +0 -342
- package/src/directive/http/http.test.js +0 -12
- package/src/directive/http/interface.ts +0 -36
- package/src/directive/http/post-example.html +0 -30
- package/src/directive/http/post.spec.js +0 -521
- package/src/directive/http/put.spec.js +0 -23
- package/src/directive/if/if-animate-css.html +0 -57
- package/src/directive/if/if-animate-svg.html +0 -25
- package/src/directive/if/if.html +0 -19
- package/src/directive/if/if.js +0 -72
- package/src/directive/if/if.md +0 -76
- package/src/directive/if/if.spec.js +0 -293
- package/src/directive/if/if.test.js +0 -114
- package/src/directive/include/include.html +0 -19
- package/src/directive/include/include.js +0 -151
- package/src/directive/include/include.md +0 -87
- package/src/directive/include/include.spec.js +0 -734
- package/src/directive/include/include.test.js +0 -12
- package/src/directive/init/init.html +0 -19
- package/src/directive/init/init.js +0 -22
- package/src/directive/init/init.md +0 -41
- package/src/directive/init/init.spec.js +0 -68
- package/src/directive/init/init.test.js +0 -12
- package/src/directive/inject/inject.html +0 -19
- package/src/directive/inject/inject.js +0 -35
- package/src/directive/inject/inject.spec.js +0 -108
- package/src/directive/inject/inject.test.js +0 -12
- package/src/directive/input/input-example.html +0 -15
- package/src/directive/input/input.html +0 -19
- package/src/directive/input/input.js +0 -1078
- package/src/directive/input/input.md +0 -706
- package/src/directive/input/input.spec.js +0 -3700
- package/src/directive/input/input.test.js +0 -12
- package/src/directive/messages/messages.html +0 -22
- package/src/directive/messages/messages.js +0 -349
- package/src/directive/messages/messages.md +0 -543
- package/src/directive/messages/messages.spec.js +0 -1083
- package/src/directive/messages/messages.test.js +0 -12
- package/src/directive/model/change.md +0 -25
- package/src/directive/model/model.html +0 -19
- package/src/directive/model/model.js +0 -1170
- package/src/directive/model/model.spec.js +0 -1976
- package/src/directive/model/model.test.js +0 -12
- package/src/directive/model-options/model-option.test.js +0 -12
- package/src/directive/model-options/model-options.html +0 -22
- package/src/directive/model-options/model-options.js +0 -142
- package/src/directive/model-options/model-options.md +0 -407
- package/src/directive/model-options/model-options.spec.js +0 -1022
- package/src/directive/non-bindable/non-bindable.html +0 -22
- package/src/directive/non-bindable/non-bindable.js +0 -9
- package/src/directive/non-bindable/non-bindable.spec.js +0 -59
- package/src/directive/non-bindable/non-bindable.test.js +0 -12
- package/src/directive/observe/observe-demo.html +0 -184
- package/src/directive/observe/observe.html +0 -19
- package/src/directive/observe/observe.js +0 -41
- package/src/directive/observe/observe.spec.js +0 -106
- package/src/directive/observe/observe.test.js +0 -10
- package/src/directive/on/on.html +0 -19
- package/src/directive/on/on.spec.js +0 -215
- package/src/directive/on/on.test.js +0 -12
- package/src/directive/options/options-example.html +0 -17
- package/src/directive/options/options.html +0 -22
- package/src/directive/options/options.js +0 -542
- package/src/directive/options/options.md +0 -179
- package/src/directive/options/options.spec.js +0 -3554
- package/src/directive/options/options.test.js +0 -12
- package/src/directive/ref/href.html +0 -19
- package/src/directive/ref/href.spec.js +0 -141
- package/src/directive/ref/href.test.js +0 -19
- package/src/directive/ref/ref.html +0 -19
- package/src/directive/ref/ref.js +0 -89
- package/src/directive/ref/ref.spec.js +0 -546
- package/src/directive/repeat/repeat.html +0 -19
- package/src/directive/repeat/repeat.js +0 -333
- package/src/directive/repeat/repeat.md +0 -330
- package/src/directive/repeat/repeat.spec.js +0 -1209
- package/src/directive/repeat/repeat.test.js +0 -12
- package/src/directive/script/script.html +0 -19
- package/src/directive/script/script.js +0 -17
- package/src/directive/script/script.md +0 -11
- package/src/directive/script/script.spec.js +0 -47
- package/src/directive/script/script.test.js +0 -12
- package/src/directive/select/select.html +0 -19
- package/src/directive/select/select.js +0 -594
- package/src/directive/select/select.md +0 -74
- package/src/directive/select/select.spec.js +0 -2566
- package/src/directive/select/select.test.js +0 -12
- package/src/directive/setter/setter.html +0 -19
- package/src/directive/setter/setter.js +0 -59
- package/src/directive/setter/setter.spec.js +0 -100
- package/src/directive/setter/setter.test.js +0 -12
- package/src/directive/show-hide/show-hide.html +0 -22
- package/src/directive/show-hide/show-hide.js +0 -65
- package/src/directive/show-hide/show-hide.md +0 -255
- package/src/directive/show-hide/show-hide.spec.js +0 -268
- package/src/directive/show-hide/show-hide.test.js +0 -12
- package/src/directive/style/style.html +0 -19
- package/src/directive/style/style.js +0 -27
- package/src/directive/style/style.md +0 -23
- package/src/directive/style/style.spec.js +0 -183
- package/src/directive/style/style.test.js +0 -12
- package/src/directive/switch/switch.html +0 -19
- package/src/directive/switch/switch.js +0 -133
- package/src/directive/switch/switch.md +0 -66
- package/src/directive/switch/switch.spec.js +0 -509
- package/src/directive/switch/switch.test.js +0 -12
- package/src/directive/transclude/transclude.js +0 -122
- package/src/directive/validators/validators.html +0 -22
- package/src/directive/validators/validators.js +0 -346
- package/src/directive/validators/validators.spec.js +0 -740
- package/src/directive/validators/validators.test.js +0 -12
- package/src/filters/filter.js +0 -213
- package/src/filters/filter.spec.js +0 -719
- package/src/filters/filters.html +0 -22
- package/src/filters/filters.js +0 -239
- package/src/filters/filters.spec.js +0 -36
- package/src/filters/filters.test.js +0 -12
- package/src/filters/interface.ts +0 -9
- package/src/filters/limit-to.js +0 -55
- package/src/filters/limit-to.spec.js +0 -252
- package/src/filters/order-by.js +0 -181
- package/src/filters/order-by.spec.js +0 -883
- package/src/index.js +0 -6
- package/src/index.spec.js +0 -11
- package/src/injection-tokens.js +0 -81
- package/src/interface.ts +0 -430
- package/src/ng.js +0 -291
- package/src/ng.spec.js +0 -45
- package/src/router/common/trace.js +0 -240
- package/src/router/directives/component-example.html +0 -37
- package/src/router/directives/state-directives.html +0 -22
- package/src/router/directives/state-directives.js +0 -393
- package/src/router/directives/state-directives.md +0 -435
- package/src/router/directives/state-directives.spec.js +0 -1091
- package/src/router/directives/state-directives.test.js +0 -10
- package/src/router/directives/view-directive.js +0 -489
- package/src/router/directives/view-directive.spec.js +0 -1921
- package/src/router/directives/view-directive.test.js +0 -10
- package/src/router/directives/view-directives.html +0 -22
- package/src/router/glob/glob.html +0 -19
- package/src/router/glob/glob.js +0 -102
- package/src/router/glob/glob.spec.js +0 -108
- package/src/router/glob/glob.test.js +0 -12
- package/src/router/hooks/core-resolvables.js +0 -38
- package/src/router/hooks/ignored-transition.js +0 -25
- package/src/router/hooks/invalid-transition.js +0 -14
- package/src/router/hooks/lazy-load.js +0 -104
- package/src/router/hooks/on-enter-exit-retain.js +0 -55
- package/src/router/hooks/redirect-to.js +0 -38
- package/src/router/hooks/resolve.js +0 -57
- package/src/router/hooks/update-globals.js +0 -34
- package/src/router/hooks/url.js +0 -34
- package/src/router/hooks/views.js +0 -41
- package/src/router/params/interface.ts +0 -626
- package/src/router/params/param-factory.js +0 -23
- package/src/router/params/param-type.js +0 -133
- package/src/router/params/param-types.js +0 -153
- package/src/router/params/param.js +0 -243
- package/src/router/params/state-params.js +0 -36
- package/src/router/path/path-node.js +0 -78
- package/src/router/path/path-utils.js +0 -207
- package/src/router/resolve/interface.ts +0 -208
- package/src/router/resolve/resolvable.js +0 -123
- package/src/router/resolve/resolve-context.js +0 -190
- package/src/router/router-test-hashbang.html +0 -45
- package/src/router/router-test.html +0 -41
- package/src/router/router.html +0 -22
- package/src/router/router.js +0 -54
- package/src/router/router.test.js +0 -12
- package/src/router/services.spec.js +0 -52
- package/src/router/state/interface.ts +0 -1007
- package/src/router/state/state-builder.js +0 -376
- package/src/router/state/state-builder.spec.js +0 -86
- package/src/router/state/state-matcher.js +0 -64
- package/src/router/state/state-object.js +0 -118
- package/src/router/state/state-queue-manager.js +0 -95
- package/src/router/state/state-registry.js +0 -262
- package/src/router/state/state-service.js +0 -687
- package/src/router/state/state.html +0 -23
- package/src/router/state/state.spec.js +0 -1002
- package/src/router/state/state.test.js +0 -12
- package/src/router/state/target-state.js +0 -162
- package/src/router/state/views.js +0 -195
- package/src/router/state-filter.spec.js +0 -139
- package/src/router/state-filters.js +0 -46
- package/src/router/template-factory.html +0 -19
- package/src/router/template-factory.js +0 -249
- package/src/router/template-factory.spec.js +0 -146
- package/src/router/template-factory.test.js +0 -12
- package/src/router/transition/hook-builder.js +0 -137
- package/src/router/transition/hook-registry.js +0 -181
- package/src/router/transition/interface.js +0 -18
- package/src/router/transition/interface.ts +0 -922
- package/src/router/transition/reject-factory.js +0 -122
- package/src/router/transition/transition-event-type.js +0 -26
- package/src/router/transition/transition-hook.js +0 -199
- package/src/router/transition/transition-service.js +0 -297
- package/src/router/transition/transition.js +0 -653
- package/src/router/url/url-config.js +0 -155
- package/src/router/url/url-matcher.js +0 -532
- package/src/router/url/url-rule.js +0 -231
- package/src/router/url/url-rules.js +0 -350
- package/src/router/url/url-service.js +0 -446
- package/src/router/url/url-service.spec.js +0 -1288
- package/src/router/url/url.html +0 -19
- package/src/router/url/url.test.js +0 -12
- package/src/router/view/interface.ts +0 -51
- package/src/router/view/view.html +0 -19
- package/src/router/view/view.js +0 -262
- package/src/router/view/view.spec.js +0 -100
- package/src/router/view/view.test.js +0 -12
- package/src/router/view-hook.spec.js +0 -215
- package/src/router/view-scroll.js +0 -33
- package/src/router/view-scroll.spec.js +0 -72
- package/src/services/anchor-scroll/anchor-scroll.html +0 -76
- package/src/services/anchor-scroll/anchor-scroll.js +0 -147
- package/src/services/exception/exception-handler.js +0 -75
- package/src/services/exception/interface.ts +0 -7
- package/src/services/http/http.html +0 -23
- package/src/services/http/http.js +0 -1109
- package/src/services/http/http.spec.js +0 -4320
- package/src/services/http/http.test.js +0 -11
- package/src/services/http/interface.ts +0 -256
- package/src/services/http/template-request.spec.js +0 -220
- package/src/services/location/interface.ts +0 -70
- package/src/services/location/location.html +0 -22
- package/src/services/location/location.js +0 -1006
- package/src/services/location/location.spec.js +0 -3792
- package/src/services/location/location.test.js +0 -12
- package/src/services/log/interface.ts +0 -39
- package/src/services/log/log.html +0 -19
- package/src/services/log/log.js +0 -74
- package/src/services/log/log.spec.js +0 -64
- package/src/services/log/log.test.js +0 -12
- package/src/services/pubsub/pubsub.html +0 -19
- package/src/services/pubsub/pubsub.js +0 -349
- package/src/services/pubsub/pubsub.spec.js +0 -400
- package/src/services/pubsub/pubsub.test.js +0 -12
- package/src/services/sce/sce.html +0 -19
- package/src/services/sce/sce.js +0 -852
- package/src/services/sce/sce.spec.js +0 -617
- package/src/services/sce/sce.test.js +0 -12
- package/src/services/template-cache/template-cache.html +0 -22
- package/src/services/template-cache/template-cache.js +0 -15
- package/src/services/template-cache/template-cache.spec.js +0 -134
- package/src/services/template-cache/template-cache.test.js +0 -12
- package/src/services/template-request/interface.ts +0 -23
- package/src/services/template-request/template-request.js +0 -142
- package/src/shared/cache.js +0 -7
- package/src/shared/common.js +0 -365
- package/src/shared/common.spec.js +0 -294
- package/src/shared/constants.js +0 -21
- package/src/shared/dom.js +0 -716
- package/src/shared/hof.js +0 -157
- package/src/shared/hof.spec.js +0 -60
- package/src/shared/interface.ts +0 -21
- package/src/shared/min-err.spec.js +0 -178
- package/src/shared/noderef.js +0 -225
- package/src/shared/predicates.js +0 -34
- package/src/shared/queue.js +0 -105
- package/src/shared/queue.spec.js +0 -80
- package/src/shared/shared.html +0 -24
- package/src/shared/shared.test.js +0 -12
- package/src/shared/strings.js +0 -142
- package/src/shared/strings.spec.js +0 -40
- package/src/shared/test-utils.js +0 -47
- package/src/shared/url-utils/interface.ts +0 -54
- package/src/shared/url-utils/url-utils.html +0 -22
- package/src/shared/url-utils/url-utils.js +0 -122
- package/src/shared/url-utils/url-utils.spec.js +0 -148
- package/src/shared/url-utils/url-utils.test.js +0 -12
- package/src/shared/utils.js +0 -1255
- package/src/shared/utils.spec.js +0 -178
- package/src/src.html +0 -21
- package/src/src.test.js +0 -10
- package/tsconfig.json +0 -19
- package/tsconfig.types.json +0 -14
- package/typedoc.json +0 -8
- package/utils/express.js +0 -203
- package/utils/version.cjs +0 -23
- package/vite.config.js +0 -14
|
@@ -1,1288 +0,0 @@
|
|
|
1
|
-
import { dealoc } from "../../shared/dom.js";
|
|
2
|
-
import { Angular } from "../../angular.js";
|
|
3
|
-
import { map, find } from "../../shared/common.js";
|
|
4
|
-
|
|
5
|
-
describe("UrlMatcher", () => {
|
|
6
|
-
let $url;
|
|
7
|
-
let $injector;
|
|
8
|
-
let $location;
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
dealoc(document.getElementById("app"));
|
|
12
|
-
window.angular = new Angular();
|
|
13
|
-
window.angular
|
|
14
|
-
.module("defaultModule", [])
|
|
15
|
-
.config(
|
|
16
|
-
($locationProvider) =>
|
|
17
|
-
($locationProvider.html5ModeConf.enabled = false),
|
|
18
|
-
);
|
|
19
|
-
$injector = window.angular.bootstrap(document.getElementById("app"), [
|
|
20
|
-
"defaultModule",
|
|
21
|
-
]);
|
|
22
|
-
|
|
23
|
-
$injector.invoke((_$url_, _$location_) => {
|
|
24
|
-
$url = _$url_;
|
|
25
|
-
$location = _$location_;
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe("provider", () => {
|
|
30
|
-
it("should factory matchers with correct configuration", () => {
|
|
31
|
-
$url.config.caseInsensitive(false);
|
|
32
|
-
expect($url.compile("/hello").exec("/HELLO")).toBeNull();
|
|
33
|
-
|
|
34
|
-
$url.config.caseInsensitive(true);
|
|
35
|
-
expect($url.compile("/hello").exec("/HELLO")).toEqual({});
|
|
36
|
-
|
|
37
|
-
$url.config.strictMode(true);
|
|
38
|
-
expect($url.compile("/hello").exec("/hello/")).toBeNull();
|
|
39
|
-
|
|
40
|
-
$url.config.strictMode(false);
|
|
41
|
-
expect($url.compile("/hello").exec("/hello/")).toEqual({});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("should correctly validate UrlMatcher interface", () => {
|
|
45
|
-
let m = $url.compile("/");
|
|
46
|
-
expect($url.isMatcher(m)).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("should match static URLs", () => {
|
|
51
|
-
expect($url.compile("/hello/world").exec("/hello/world")).toEqual({});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("should match static case insensitive URLs", () => {
|
|
55
|
-
expect(
|
|
56
|
-
$url
|
|
57
|
-
.compile("/hello/world", { caseInsensitive: true })
|
|
58
|
-
.exec("/heLLo/World"),
|
|
59
|
-
).toEqual({});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("should match against the entire path", () => {
|
|
63
|
-
const matcher = $url.compile("/hello/world", { strict: true });
|
|
64
|
-
expect(matcher.exec("/hello/world/")).toBeNull();
|
|
65
|
-
expect(matcher.exec("/hello/world/suffix")).toBeNull();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("should parse parameter placeholders", () => {
|
|
69
|
-
const matcher = $url.compile(
|
|
70
|
-
"/users/:id/details/{type}/{repeat:[0-9]+}?from&to",
|
|
71
|
-
);
|
|
72
|
-
expect(matcher.parameters().map((x) => x.id)).toEqual([
|
|
73
|
-
"id",
|
|
74
|
-
"type",
|
|
75
|
-
"repeat",
|
|
76
|
-
"from",
|
|
77
|
-
"to",
|
|
78
|
-
]);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("should encode and decode duplicate query string values as array", () => {
|
|
82
|
-
const matcher = $url.compile("/?foo"),
|
|
83
|
-
array = { foo: ["bar", "baz"] };
|
|
84
|
-
expect(matcher.exec("/", array)).toEqual(array);
|
|
85
|
-
expect(matcher.format(array)).toBe("/?foo=bar&foo=baz");
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe("snake-case parameters", () => {
|
|
89
|
-
it("should match if properly formatted", () => {
|
|
90
|
-
const matcher = $url.compile(
|
|
91
|
-
"/users/?from&to&snake-case&snake-case-triple",
|
|
92
|
-
);
|
|
93
|
-
expect(matcher.parameters().map((x) => x.id)).toEqual([
|
|
94
|
-
"from",
|
|
95
|
-
"to",
|
|
96
|
-
"snake-case",
|
|
97
|
-
"snake-case-triple",
|
|
98
|
-
]);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("should not match if invalid", () => {
|
|
102
|
-
let err =
|
|
103
|
-
"Invalid parameter name '-snake' in pattern '/users/?from&to&-snake'";
|
|
104
|
-
expect(() => {
|
|
105
|
-
$url.compile("/users/?from&to&-snake");
|
|
106
|
-
}).toThrowError(err);
|
|
107
|
-
|
|
108
|
-
err =
|
|
109
|
-
"Invalid parameter name 'snake-' in pattern '/users/?from&to&snake-'";
|
|
110
|
-
expect(() => {
|
|
111
|
-
$url.compile("/users/?from&to&snake-");
|
|
112
|
-
}).toThrowError(err);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe("parameters containing periods", () => {
|
|
117
|
-
it("should match if properly formatted", () => {
|
|
118
|
-
const matcher = $url.compile(
|
|
119
|
-
"/users/?from&to&with.periods&with.periods.also",
|
|
120
|
-
);
|
|
121
|
-
const params = matcher.parameters().map(function (p) {
|
|
122
|
-
return p.id;
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
expect(params.sort()).toEqual([
|
|
126
|
-
"from",
|
|
127
|
-
"to",
|
|
128
|
-
"with.periods",
|
|
129
|
-
"with.periods.also",
|
|
130
|
-
]);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("should not match if invalid", () => {
|
|
134
|
-
let err = new Error(
|
|
135
|
-
"Invalid parameter name '.periods' in pattern '/users/?from&to&.periods'",
|
|
136
|
-
);
|
|
137
|
-
expect(() => {
|
|
138
|
-
$url.compile("/users/?from&to&.periods");
|
|
139
|
-
}).toThrow(err);
|
|
140
|
-
|
|
141
|
-
err = new Error(
|
|
142
|
-
"Invalid parameter name 'periods.' in pattern '/users/?from&to&periods.'",
|
|
143
|
-
);
|
|
144
|
-
expect(() => {
|
|
145
|
-
$url.compile("/users/?from&to&periods.");
|
|
146
|
-
}).toThrow(err);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
describe(".exec()", () => {
|
|
151
|
-
it("should capture parameter values", () => {
|
|
152
|
-
const m = $url.compile(
|
|
153
|
-
"/users/:id/details/{type}/{repeat:[0-9]+}?from&to",
|
|
154
|
-
{ strict: false },
|
|
155
|
-
);
|
|
156
|
-
expect(m.exec("/users/123/details//0", {})).toEqual({
|
|
157
|
-
id: "123",
|
|
158
|
-
type: "",
|
|
159
|
-
repeat: "0",
|
|
160
|
-
to: undefined,
|
|
161
|
-
from: undefined,
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it("should capture catch-all parameters", () => {
|
|
166
|
-
const m = $url.compile("/document/*path");
|
|
167
|
-
expect(m.exec("/document/a/b/c", {})).toEqual({ path: "a/b/c" });
|
|
168
|
-
expect(m.exec("/document/", {})).toEqual({ path: "" });
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("should use the optional regexp with curly brace placeholders", () => {
|
|
172
|
-
const m = $url.compile(
|
|
173
|
-
"/users/:id/details/{type}/{repeat:[0-9]+}?from&to",
|
|
174
|
-
);
|
|
175
|
-
expect(
|
|
176
|
-
m.exec("/users/123/details/what/thisShouldBeDigits", {}),
|
|
177
|
-
).toBeNull();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it("should not use optional regexp for '/'", () => {
|
|
181
|
-
const m = $url.compile("/{language:(?:fr|en|de)}");
|
|
182
|
-
expect(m.exec("/", {})).toBeNull();
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it("should work with empty default value", () => {
|
|
186
|
-
const m = $url.compile("/foo/:str", {
|
|
187
|
-
state: { params: { str: { value: "" } } },
|
|
188
|
-
});
|
|
189
|
-
expect(m.exec("/foo/", {})).toEqual({ str: "" });
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("should work with empty default value for regex", () => {
|
|
193
|
-
const m = $url.compile("/foo/{param:(?:foo|bar|)}", {
|
|
194
|
-
state: { params: { param: { value: "" } } },
|
|
195
|
-
});
|
|
196
|
-
expect(m.exec("/foo/", {})).toEqual({ param: "" });
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it("should treat the URL as already decoded and does not decode it further", () => {
|
|
200
|
-
expect($url.compile("/users/:id").exec("/users/100%25", {})).toEqual({
|
|
201
|
-
id: "100%25",
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
xit("should allow embedded capture groups", () => {
|
|
206
|
-
const shouldPass = {
|
|
207
|
-
"/url/{matchedParam:([a-z]+)}/child/{childParam}":
|
|
208
|
-
"/url/someword/child/childParam",
|
|
209
|
-
"/url/{matchedParam:([a-z]+)}/child/{childParam}?foo":
|
|
210
|
-
"/url/someword/child/childParam",
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
Object.entries(shouldPass).forEach(function ([route, url]) {
|
|
214
|
-
expect($url.compile(route).exec(url, {})).toEqual({
|
|
215
|
-
childParam: "childParam",
|
|
216
|
-
matchedParam: "someword",
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
it("should throw on unbalanced capture list", () => {
|
|
222
|
-
const shouldThrow = {
|
|
223
|
-
"/url/{matchedParam:([a-z]+)}/child/{childParam}":
|
|
224
|
-
"/url/someword/child/childParam",
|
|
225
|
-
"/url/{matchedParam:([a-z]+)}/child/{childParam}?foo":
|
|
226
|
-
"/url/someword/child/childParam",
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
Object.entries(shouldThrow).forEach(function ([route, url]) {
|
|
230
|
-
expect(() => {
|
|
231
|
-
$url.compile(route).exec(url, {});
|
|
232
|
-
}).toThrowError("Unbalanced capture group in route '" + route + "'");
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
const shouldPass = {
|
|
236
|
-
"/url/{matchedParam:[a-z]+}/child/{childParam}":
|
|
237
|
-
"/url/someword/child/childParam",
|
|
238
|
-
"/url/{matchedParam:[a-z]+}/child/{childParam}?foo":
|
|
239
|
-
"/url/someword/child/childParam",
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
Object.entries(shouldPass).forEach(function ([route, url]) {
|
|
243
|
-
expect(() => {
|
|
244
|
-
$url.compile(route).exec(url, {});
|
|
245
|
-
}).not.toThrow();
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
describe(".format()", () => {
|
|
251
|
-
it("should reconstitute the URL", () => {
|
|
252
|
-
const m = $url.compile("/users/:id/details/{type}/{repeat:[0-9]+}?from"),
|
|
253
|
-
params = {
|
|
254
|
-
id: "123",
|
|
255
|
-
type: "default",
|
|
256
|
-
repeat: 444,
|
|
257
|
-
ignored: "value",
|
|
258
|
-
from: "1970",
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
expect(m.format(params)).toEqual(
|
|
262
|
-
"/users/123/details/default/444?from=1970",
|
|
263
|
-
);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it("should encode URL parameters", () => {
|
|
267
|
-
expect($url.compile("/users/:id").format({ id: "100%" })).toEqual(
|
|
268
|
-
"/users/100%25",
|
|
269
|
-
);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it("encodes URL parameters with hashes", () => {
|
|
273
|
-
const m = $url.compile("/users/:id#:section");
|
|
274
|
-
expect(m.format({ id: "bob", section: "contact-details" })).toEqual(
|
|
275
|
-
"/users/bob#contact-details",
|
|
276
|
-
);
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
it("should trim trailing slashes when the terminal value is optional", () => {
|
|
280
|
-
const config = {
|
|
281
|
-
state: { params: { id: { squash: true, value: "123" } } },
|
|
282
|
-
},
|
|
283
|
-
m = $url.compile("/users/:id", config),
|
|
284
|
-
params = { id: "123" };
|
|
285
|
-
|
|
286
|
-
expect(m.format(params)).toEqual("/users");
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
it("should format query parameters from parent, child, grandchild matchers", () => {
|
|
290
|
-
const m = $url.compile("/parent?qParent");
|
|
291
|
-
const m2 = m.append($url.compile("/child?qChild"));
|
|
292
|
-
const m3 = m2.append($url.compile("/grandchild?qGrandchild"));
|
|
293
|
-
|
|
294
|
-
const params = {
|
|
295
|
-
qParent: "parent",
|
|
296
|
-
qChild: "child",
|
|
297
|
-
qGrandchild: "grandchild",
|
|
298
|
-
};
|
|
299
|
-
const url =
|
|
300
|
-
"/parent/child/grandchild?qParent=parent&qChild=child&qGrandchild=grandchild";
|
|
301
|
-
|
|
302
|
-
const formatted = m3.format(params);
|
|
303
|
-
expect(formatted).toBe(url);
|
|
304
|
-
expect(m3.exec(url.split("?")[0], params)).toEqual(params);
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
describe(".append()", () => {
|
|
309
|
-
it("should append matchers", () => {
|
|
310
|
-
const matcher = $url
|
|
311
|
-
.compile("/users/:id/details/{type}?from")
|
|
312
|
-
.append($url.compile("/{repeat:[0-9]+}?to"));
|
|
313
|
-
const params = matcher.parameters();
|
|
314
|
-
expect(params.map((x) => x.id)).toEqual([
|
|
315
|
-
"id",
|
|
316
|
-
"type",
|
|
317
|
-
"from",
|
|
318
|
-
"repeat",
|
|
319
|
-
"to",
|
|
320
|
-
]);
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
it("should return a new matcher", () => {
|
|
324
|
-
const base = $url.compile("/users/:id/details/{type}?from");
|
|
325
|
-
const matcher = base.append($url.compile("/{repeat:[0-9]+}?to"));
|
|
326
|
-
expect(matcher).not.toBe(base);
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
it("should respect $urlProvider.strictMode", () => {
|
|
330
|
-
let m = $url.compile("/");
|
|
331
|
-
$url.config.strictMode(false);
|
|
332
|
-
m = m.append($url.compile("foo"));
|
|
333
|
-
expect(m.exec("/foo")).toEqual({});
|
|
334
|
-
expect(m.exec("/foo/")).toEqual({});
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
it("should respect $urlProvider.caseInsensitive", () => {
|
|
338
|
-
let m = $url.compile("/");
|
|
339
|
-
$url.config.caseInsensitive(true);
|
|
340
|
-
m = m.append($url.compile("foo"));
|
|
341
|
-
expect(m.exec("/foo")).toEqual({});
|
|
342
|
-
expect(m.exec("/FOO")).toEqual({});
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
it("should respect $urlProvider.caseInsensitive when validating regex params", () => {
|
|
346
|
-
let m = $url.compile("/");
|
|
347
|
-
$url.config.caseInsensitive(true);
|
|
348
|
-
m = m.append($url.compile("foo/{param:bar}"));
|
|
349
|
-
expect(m.validates({ param: "BAR" })).toEqual(true);
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
it("should generate/match params in the proper order", () => {
|
|
353
|
-
let m = $url.compile("/foo?queryparam");
|
|
354
|
-
m = m.append($url.compile("/bar/:pathparam"));
|
|
355
|
-
expect(m.exec("/foo/bar/pathval", { queryparam: "queryval" })).toEqual({
|
|
356
|
-
pathparam: "pathval",
|
|
357
|
-
queryparam: "queryval",
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
describe("multivalue-query-parameters", () => {
|
|
363
|
-
it("should handle .is() for an array of values", () => {
|
|
364
|
-
const m = $url.compile("/foo?{param1:int}"),
|
|
365
|
-
param = m.parameter("param1");
|
|
366
|
-
expect(param.type.is([1, 2, 3])).toBe(true);
|
|
367
|
-
expect(param.type.is([1, "2", 3])).toBe(false);
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
it("should handle .equals() for two arrays of values", () => {
|
|
371
|
-
const m = $url.compile("/foo?{param1:int}&{param2:date}"),
|
|
372
|
-
param1 = m.parameter("param1"),
|
|
373
|
-
param2 = m.parameter("param2");
|
|
374
|
-
|
|
375
|
-
expect(param1.type.equals([1, 2, 3], [1, 2, 3])).toBe(true);
|
|
376
|
-
expect(param1.type.equals([1, 2, 3], [1, 2])).toBe(false);
|
|
377
|
-
expect(
|
|
378
|
-
param2.type.equals(
|
|
379
|
-
[new Date(2014, 11, 15), new Date(2014, 10, 15)],
|
|
380
|
-
[new Date(2014, 11, 15), new Date(2014, 10, 15)],
|
|
381
|
-
),
|
|
382
|
-
).toBe(true);
|
|
383
|
-
expect(
|
|
384
|
-
param2.type.equals(
|
|
385
|
-
[new Date(2014, 11, 15), new Date(2014, 9, 15)],
|
|
386
|
-
[new Date(2014, 11, 15), new Date(2014, 10, 15)],
|
|
387
|
-
),
|
|
388
|
-
).toBe(false);
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
it("should conditionally be wrapped in an array by default", () => {
|
|
392
|
-
const m = $url.compile("/foo?param1");
|
|
393
|
-
|
|
394
|
-
// empty array [] is treated like "undefined"
|
|
395
|
-
expect(m.format({ param1: undefined })).toBe("/foo");
|
|
396
|
-
expect(m.format({ param1: [] })).toBe("/foo");
|
|
397
|
-
expect(m.format({ param1: "" })).toBe("/foo");
|
|
398
|
-
expect(m.format({ param1: "1" })).toBe("/foo?param1=1");
|
|
399
|
-
expect(m.format({ param1: ["1"] })).toBe("/foo?param1=1");
|
|
400
|
-
expect(m.format({ param1: ["1", "2"] })).toBe("/foo?param1=1¶m1=2");
|
|
401
|
-
|
|
402
|
-
expect(m.exec("/foo")).toEqual({ param1: undefined });
|
|
403
|
-
expect(m.exec("/foo", {})).toEqual({ param1: undefined });
|
|
404
|
-
expect(m.exec("/foo", { param1: "" })).toEqual({ param1: undefined });
|
|
405
|
-
expect(m.exec("/foo", { param1: "1" })).toEqual({ param1: "1" }); // auto unwrap single values
|
|
406
|
-
expect(m.exec("/foo", { param1: ["1", "2"] })).toEqual({
|
|
407
|
-
param1: ["1", "2"],
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
$url.url("/foo");
|
|
411
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
412
|
-
param1: undefined,
|
|
413
|
-
});
|
|
414
|
-
$url.url("/foo?param1=bar");
|
|
415
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
416
|
-
param1: "bar",
|
|
417
|
-
}); // auto unwrap
|
|
418
|
-
$url.url("/foo?param1=");
|
|
419
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
420
|
-
param1: undefined,
|
|
421
|
-
});
|
|
422
|
-
$url.url("/foo?param1=bar¶m1=baz");
|
|
423
|
-
if (Array.isArray($url.getSearch()))
|
|
424
|
-
// conditional for angular 1.0.8
|
|
425
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
426
|
-
param1: ["bar", "baz"],
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
expect(m.format({})).toBe("/foo");
|
|
430
|
-
expect(m.format({ param1: undefined })).toBe("/foo");
|
|
431
|
-
expect(m.format({ param1: "" })).toBe("/foo");
|
|
432
|
-
expect(m.format({ param1: "bar" })).toBe("/foo?param1=bar");
|
|
433
|
-
expect(m.format({ param1: ["bar"] })).toBe("/foo?param1=bar");
|
|
434
|
-
expect(m.format({ param1: ["bar", "baz"] })).toBe(
|
|
435
|
-
"/foo?param1=bar¶m1=baz",
|
|
436
|
-
);
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
it("should be wrapped in an array if array: true", () => {
|
|
440
|
-
const m = $url.compile("/foo?param1", {
|
|
441
|
-
state: { params: { param1: { array: true } } },
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
// empty array [] is treated like "undefined"
|
|
445
|
-
expect(m.format({ param1: undefined })).toBe("/foo");
|
|
446
|
-
expect(m.format({ param1: [] })).toBe("/foo");
|
|
447
|
-
expect(m.format({ param1: "" })).toBe("/foo");
|
|
448
|
-
expect(m.format({ param1: "1" })).toBe("/foo?param1=1");
|
|
449
|
-
expect(m.format({ param1: ["1"] })).toBe("/foo?param1=1");
|
|
450
|
-
expect(m.format({ param1: ["1", "2"] })).toBe("/foo?param1=1¶m1=2");
|
|
451
|
-
|
|
452
|
-
expect(m.exec("/foo")).toEqual({ param1: undefined });
|
|
453
|
-
expect(m.exec("/foo", {})).toEqual({ param1: undefined });
|
|
454
|
-
expect(m.exec("/foo", { param1: "" })).toEqual({ param1: undefined });
|
|
455
|
-
expect(m.exec("/foo", { param1: "1" })).toEqual({ param1: ["1"] });
|
|
456
|
-
expect(m.exec("/foo", { param1: ["1", "2"] })).toEqual({
|
|
457
|
-
param1: ["1", "2"],
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
$url.url("/foo");
|
|
461
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
462
|
-
param1: undefined,
|
|
463
|
-
});
|
|
464
|
-
$url.url("/foo?param1=");
|
|
465
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
466
|
-
param1: undefined,
|
|
467
|
-
});
|
|
468
|
-
$url.url("/foo?param1=bar");
|
|
469
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
470
|
-
param1: ["bar"],
|
|
471
|
-
});
|
|
472
|
-
$url.url("/foo?param1=bar¶m1=baz");
|
|
473
|
-
if (Array.isArray($url.getSearch()))
|
|
474
|
-
// conditional for angular 1.0.8
|
|
475
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
476
|
-
param1: ["bar", "baz"],
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
expect(m.format({})).toBe("/foo");
|
|
480
|
-
expect(m.format({ param1: undefined })).toBe("/foo");
|
|
481
|
-
expect(m.format({ param1: "" })).toBe("/foo");
|
|
482
|
-
expect(m.format({ param1: "bar" })).toBe("/foo?param1=bar");
|
|
483
|
-
expect(m.format({ param1: ["bar"] })).toBe("/foo?param1=bar");
|
|
484
|
-
expect(m.format({ param1: ["bar", "baz"] })).toBe(
|
|
485
|
-
"/foo?param1=bar¶m1=baz",
|
|
486
|
-
);
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
it("should be wrapped in an array if paramname looks like param[]", () => {
|
|
490
|
-
const m = $url.compile("/foo?param1[]");
|
|
491
|
-
expect(m.exec("/foo")).toEqual({ "param1[]": undefined });
|
|
492
|
-
|
|
493
|
-
$url.url("/foo?param1[]=bar");
|
|
494
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
495
|
-
"param1[]": ["bar"],
|
|
496
|
-
});
|
|
497
|
-
expect(m.format({ "param1[]": "bar" })).toBe("/foo?param1[]=bar");
|
|
498
|
-
expect(m.format({ "param1[]": ["bar"] })).toBe("/foo?param1[]=bar");
|
|
499
|
-
|
|
500
|
-
$url.url("/foo?param1[]=bar¶m1[]=baz");
|
|
501
|
-
if (Array.isArray($url.getSearch()))
|
|
502
|
-
// conditional for angular 1.0.8
|
|
503
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
504
|
-
"param1[]": ["bar", "baz"],
|
|
505
|
-
});
|
|
506
|
-
expect(m.format({ "param1[]": ["bar", "baz"] })).toBe(
|
|
507
|
-
"/foo?param1[]=bar¶m1[]=baz",
|
|
508
|
-
);
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
// Test for issue #2222
|
|
512
|
-
it("should return default value, if query param is missing.", () => {
|
|
513
|
-
const m = $url.compile("/state?param1¶m2¶m3¶m5", {
|
|
514
|
-
state: {
|
|
515
|
-
params: {
|
|
516
|
-
param1: "value1",
|
|
517
|
-
param2: { array: true, value: ["value2"] },
|
|
518
|
-
param3: { array: true, value: [] },
|
|
519
|
-
param5: {
|
|
520
|
-
array: true,
|
|
521
|
-
value: () => {
|
|
522
|
-
return [];
|
|
523
|
-
},
|
|
524
|
-
},
|
|
525
|
-
},
|
|
526
|
-
},
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
const expected = {
|
|
530
|
-
param1: "value1",
|
|
531
|
-
param2: ["value2"],
|
|
532
|
-
param3: [],
|
|
533
|
-
param5: [],
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
// Parse url to get Param.value()
|
|
537
|
-
const parsed = m.exec("/state");
|
|
538
|
-
expect(parsed).toEqual(expected);
|
|
539
|
-
|
|
540
|
-
// Pass again through Param.value() for normalization (like transitionTo)
|
|
541
|
-
const paramDefs = m.parameters();
|
|
542
|
-
const values = map(parsed, function (val, key) {
|
|
543
|
-
return find(paramDefs, function (def) {
|
|
544
|
-
return def.id === key;
|
|
545
|
-
}).value(val);
|
|
546
|
-
});
|
|
547
|
-
expect(values).toEqual(expected);
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
it("should not be wrapped by ng-router into an array if array: false", () => {
|
|
551
|
-
const m = $url.compile("/foo?param1", {
|
|
552
|
-
state: { params: { param1: { array: false } } },
|
|
553
|
-
});
|
|
554
|
-
expect(m.exec("/foo")).toEqual({ param1: undefined });
|
|
555
|
-
|
|
556
|
-
$url.url("/foo?param1=bar");
|
|
557
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
558
|
-
param1: "bar",
|
|
559
|
-
});
|
|
560
|
-
expect(m.format({ param1: "bar" })).toBe("/foo?param1=bar");
|
|
561
|
-
expect(m.format({ param1: ["bar"] })).toBe("/foo?param1=bar");
|
|
562
|
-
|
|
563
|
-
$url.url("/foo?param1=bar¶m1=baz");
|
|
564
|
-
if (Array.isArray($url.getSearch()))
|
|
565
|
-
// conditional for angular 1.0.8
|
|
566
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
567
|
-
param1: "bar,baz",
|
|
568
|
-
}); // coerced to string
|
|
569
|
-
expect(m.format({ param1: ["bar", "baz"] })).toBe(
|
|
570
|
-
"/foo?param1=bar%2Cbaz",
|
|
571
|
-
); // coerced to string
|
|
572
|
-
});
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
describe("multivalue-path-parameters", () => {
|
|
576
|
-
it("should behave as a single-value by default", () => {
|
|
577
|
-
const m = $url.compile("/foo/:param1");
|
|
578
|
-
|
|
579
|
-
expect(m.exec("/foo/")).toEqual({ param1: "" });
|
|
580
|
-
|
|
581
|
-
expect(m.exec("/foo/bar")).toEqual({ param1: "bar" });
|
|
582
|
-
expect(m.format({ param1: "bar" })).toBe("/foo/bar");
|
|
583
|
-
expect(m.format({ param1: ["bar", "baz"] })).toBe("/foo/bar%2Cbaz"); // coerced to string
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
it("should be split on - in url and wrapped in an array if array: true", () => {
|
|
587
|
-
const m = $url.compile("/foo/:param1", {
|
|
588
|
-
state: { params: { param1: { array: true } } },
|
|
589
|
-
});
|
|
590
|
-
|
|
591
|
-
expect(m.exec("/foo/")).toEqual({ param1: undefined });
|
|
592
|
-
expect(m.exec("/foo/bar")).toEqual({ param1: ["bar"] });
|
|
593
|
-
$url.url("/foo/bar-baz");
|
|
594
|
-
expect(m.exec($location.getUrl())).toEqual({
|
|
595
|
-
param1: ["bar", "baz"],
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
expect(m.format({ param1: [] })).toEqual("/foo/");
|
|
599
|
-
expect(m.format({ param1: ["bar"] })).toEqual("/foo/bar");
|
|
600
|
-
expect(m.format({ param1: ["bar", "baz"] })).toEqual("/foo/bar-baz");
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
it("should behave similar to multi-value query params", () => {
|
|
604
|
-
const m = $url.compile("/foo/:param1[]");
|
|
605
|
-
|
|
606
|
-
// empty array [] is treated like "undefined"
|
|
607
|
-
expect(m.format({ "param1[]": undefined })).toBe("/foo/");
|
|
608
|
-
expect(m.format({ "param1[]": [] })).toBe("/foo/");
|
|
609
|
-
expect(m.format({ "param1[]": "" })).toBe("/foo/");
|
|
610
|
-
expect(m.format({ "param1[]": "1" })).toBe("/foo/1");
|
|
611
|
-
expect(m.format({ "param1[]": ["1"] })).toBe("/foo/1");
|
|
612
|
-
expect(m.format({ "param1[]": ["1", "2"] })).toBe("/foo/1-2");
|
|
613
|
-
|
|
614
|
-
expect(m.exec("/foo/")).toEqual({ "param1[]": undefined });
|
|
615
|
-
expect(m.exec("/foo/1")).toEqual({ "param1[]": ["1"] });
|
|
616
|
-
expect(m.exec("/foo/1-2")).toEqual({ "param1[]": ["1", "2"] });
|
|
617
|
-
|
|
618
|
-
$url.url("/foo/");
|
|
619
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
620
|
-
"param1[]": undefined,
|
|
621
|
-
});
|
|
622
|
-
$url.url("/foo/bar");
|
|
623
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
624
|
-
"param1[]": ["bar"],
|
|
625
|
-
});
|
|
626
|
-
$url.url("/foo/bar-baz");
|
|
627
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
628
|
-
"param1[]": ["bar", "baz"],
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
expect(m.format({})).toBe("/foo/");
|
|
632
|
-
expect(m.format({ "param1[]": undefined })).toBe("/foo/");
|
|
633
|
-
expect(m.format({ "param1[]": "" })).toBe("/foo/");
|
|
634
|
-
expect(m.format({ "param1[]": "bar" })).toBe("/foo/bar");
|
|
635
|
-
expect(m.format({ "param1[]": ["bar"] })).toBe("/foo/bar");
|
|
636
|
-
expect(m.format({ "param1[]": ["bar", "baz"] })).toBe("/foo/bar-baz");
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
it("should be split on - in url and wrapped in an array if paramname looks like param[]", () => {
|
|
640
|
-
const m = $url.compile("/foo/:param1[]");
|
|
641
|
-
|
|
642
|
-
expect(m.exec("/foo/")).toEqual({ "param1[]": undefined });
|
|
643
|
-
expect(m.exec("/foo/bar")).toEqual({ "param1[]": ["bar"] });
|
|
644
|
-
expect(m.exec("/foo/bar-baz")).toEqual({ "param1[]": ["bar", "baz"] });
|
|
645
|
-
|
|
646
|
-
expect(m.format({ "param1[]": [] })).toEqual("/foo/");
|
|
647
|
-
expect(m.format({ "param1[]": ["bar"] })).toEqual("/foo/bar");
|
|
648
|
-
expect(m.format({ "param1[]": ["bar", "baz"] })).toEqual("/foo/bar-baz");
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
it("should allow path param arrays with '-' in the values", () => {
|
|
652
|
-
const m = $url.compile("/foo/:param1[]");
|
|
653
|
-
|
|
654
|
-
expect(m.exec("/foo/")).toEqual({ "param1[]": undefined });
|
|
655
|
-
expect(m.exec("/foo/bar\\-")).toEqual({ "param1[]": ["bar-"] });
|
|
656
|
-
expect(m.exec("/foo/bar\\--\\-baz")).toEqual({
|
|
657
|
-
"param1[]": ["bar-", "-baz"],
|
|
658
|
-
});
|
|
659
|
-
|
|
660
|
-
expect(m.format({ "param1[]": [] })).toEqual("/foo/");
|
|
661
|
-
expect(m.format({ "param1[]": ["bar-"] })).toEqual("/foo/bar%5C%2D");
|
|
662
|
-
expect(m.format({ "param1[]": ["bar-", "-baz"] })).toEqual(
|
|
663
|
-
"/foo/bar%5C%2D-%5C%2Dbaz",
|
|
664
|
-
);
|
|
665
|
-
expect(
|
|
666
|
-
m.format({ "param1[]": ["bar-bar-bar-", "-baz-baz-baz"] }),
|
|
667
|
-
).toEqual("/foo/bar%5C%2Dbar%5C%2Dbar%5C%2D-%5C%2Dbaz%5C%2Dbaz%5C%2Dbaz");
|
|
668
|
-
|
|
669
|
-
// check that we handle $location.url decodes correctly
|
|
670
|
-
$url.url(m.format({ "param1[]": ["bar-", "-baz"] }));
|
|
671
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
672
|
-
"param1[]": ["bar-", "-baz"],
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
// check that we handle $location.url decodes correctly for multiple hyphens
|
|
676
|
-
$url.url(m.format({ "param1[]": ["bar-bar-bar-", "-baz-baz-baz"] }));
|
|
677
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
678
|
-
"param1[]": ["bar-bar-bar-", "-baz-baz-baz"],
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
// check that pre-encoded values are passed correctly
|
|
682
|
-
$url.url(m.format({ "param1[]": ["%2C%20%5C%2C", "-baz"] }));
|
|
683
|
-
expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
684
|
-
"param1[]": ["%2C%20%5C%2C", "-baz"],
|
|
685
|
-
});
|
|
686
|
-
});
|
|
687
|
-
});
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
// describe("urlMatcherFactoryProvider", ( ) => {
|
|
691
|
-
// describe(".type()", ( ) => {
|
|
692
|
-
// let $url;
|
|
693
|
-
// beforeEach(
|
|
694
|
-
// module("ng.router.util", function ($urlProvider) {
|
|
695
|
-
// $url = $urlProvider;
|
|
696
|
-
// $urlProvider.type("myType", {}, ( ) => {
|
|
697
|
-
// return {
|
|
698
|
-
// decode: ( ) => {
|
|
699
|
-
// return { status: "decoded" };
|
|
700
|
-
// },
|
|
701
|
-
// is: angular.isObject,
|
|
702
|
-
// };
|
|
703
|
-
// });
|
|
704
|
-
// }),
|
|
705
|
-
// );
|
|
706
|
-
|
|
707
|
-
// it("should handle arrays properly with config-time custom type definitions", function (
|
|
708
|
-
// $stateParams,
|
|
709
|
-
// ) {
|
|
710
|
-
// const m = $url.compile("/test?{foo:myType}");
|
|
711
|
-
// expect(m.exec("/test", { foo: "1" })).toEqual({
|
|
712
|
-
// foo: { status: "decoded" },
|
|
713
|
-
// });
|
|
714
|
-
// expect(m.exec("/test", { foo: ["1", "2"] })).toEqual({
|
|
715
|
-
// foo: [{ status: "decoded" }, { status: "decoded" }],
|
|
716
|
-
// });
|
|
717
|
-
// });
|
|
718
|
-
// });
|
|
719
|
-
|
|
720
|
-
// // TODO: Fix object pollution between tests for urlMatcherConfig
|
|
721
|
-
// afterEach(function ($urlMatcherFactory) {
|
|
722
|
-
// $urlMatcherFactory.caseInsensitive(false);
|
|
723
|
-
// });
|
|
724
|
-
// });
|
|
725
|
-
|
|
726
|
-
// describe("urlMatcherFactory", ( ) => {
|
|
727
|
-
// let $url;
|
|
728
|
-
// let $url;
|
|
729
|
-
|
|
730
|
-
// beforeEach(function ($urlMatcherFactory, $url) {
|
|
731
|
-
// $url = $urlMatcherFactory;
|
|
732
|
-
// $url = $url;
|
|
733
|
-
// });
|
|
734
|
-
|
|
735
|
-
// it("compiles patterns", ( ) => {
|
|
736
|
-
// const matcher = $url.compile("/hello/world");
|
|
737
|
-
// expect(matcher instanceof UrlMatcher).toBe(true);
|
|
738
|
-
// });
|
|
739
|
-
|
|
740
|
-
// it("recognizes matchers", ( ) => {
|
|
741
|
-
// expect($url.isMatcher($url.compile("/"))).toBe(true);
|
|
742
|
-
|
|
743
|
-
// const custom = {
|
|
744
|
-
// format: angular.noop,
|
|
745
|
-
// exec: angular.noop,
|
|
746
|
-
// append: angular.noop,
|
|
747
|
-
// isRoot: angular.noop,
|
|
748
|
-
// validates: angular.noop,
|
|
749
|
-
// parameters: angular.noop,
|
|
750
|
-
// parameter: angular.noop,
|
|
751
|
-
// _getDecodedParamValue: angular.noop,
|
|
752
|
-
// };
|
|
753
|
-
// expect($url.isMatcher(custom)).toBe(true);
|
|
754
|
-
// });
|
|
755
|
-
|
|
756
|
-
// it("should handle case sensitive URL by default", ( ) => {
|
|
757
|
-
// expect($url.compile("/hello/world").exec("/heLLo/WORLD")).toBeNull();
|
|
758
|
-
// });
|
|
759
|
-
|
|
760
|
-
// it("should handle case insensitive URL", ( ) => {
|
|
761
|
-
// $url.config.caseInsensitive(true);
|
|
762
|
-
// expect($url.compile("/hello/world").exec("/heLLo/WORLD")).toEqual({});
|
|
763
|
-
// });
|
|
764
|
-
|
|
765
|
-
// describe("typed parameters", ( ) => {
|
|
766
|
-
// it("should accept object definitions", ( ) => {
|
|
767
|
-
// const type = { encode: ( ) => {}, decode: ( ) => {} };
|
|
768
|
-
// $url.type("myType1", type);
|
|
769
|
-
// expect($url.type("myType1").encode).toBe(type.encode);
|
|
770
|
-
// });
|
|
771
|
-
|
|
772
|
-
// it("should reject duplicate definitions", ( ) => {
|
|
773
|
-
// $url.type("myType2", { encode: ( ) => {}, decode: ( ) => {} });
|
|
774
|
-
// expect(( ) => {
|
|
775
|
-
// $url.type("myType2", {});
|
|
776
|
-
// }).toThrowError("A type named 'myType2' has already been defined.");
|
|
777
|
-
// });
|
|
778
|
-
|
|
779
|
-
// it("should accept injected function definitions", function (
|
|
780
|
-
// $stateParams,
|
|
781
|
-
// ) {
|
|
782
|
-
// $url.type("myType3", {}, function ($stateParams) {
|
|
783
|
-
// return {
|
|
784
|
-
// decode: ( ) => {
|
|
785
|
-
// return $stateParams;
|
|
786
|
-
// },
|
|
787
|
-
// };
|
|
788
|
-
// });
|
|
789
|
-
// expect($url.type("myType3").decode()).toBe($stateParams);
|
|
790
|
-
// });
|
|
791
|
-
|
|
792
|
-
// it("should accept annotated function definitions", function (
|
|
793
|
-
// $stateParams,
|
|
794
|
-
// ) {
|
|
795
|
-
// $url.type("myAnnotatedType", {}, [
|
|
796
|
-
// "$stateParams",
|
|
797
|
-
// function (s) {
|
|
798
|
-
// return {
|
|
799
|
-
// decode: ( ) => {
|
|
800
|
-
// return s;
|
|
801
|
-
// },
|
|
802
|
-
// };
|
|
803
|
-
// },
|
|
804
|
-
// ]);
|
|
805
|
-
// expect($url.type("myAnnotatedType").decode()).toBe($stateParams);
|
|
806
|
-
// });
|
|
807
|
-
|
|
808
|
-
// it("should match built-in types", ( ) => {
|
|
809
|
-
// const m = $url.compile("/{foo:int}/{flag:bool}");
|
|
810
|
-
// expect(m.exec("/1138/1")).toEqual({ foo: 1138, flag: true });
|
|
811
|
-
// expect(m.format({ foo: 5, flag: true })).toBe("/5/1");
|
|
812
|
-
|
|
813
|
-
// expect(m.exec("/-1138/1")).toEqual({ foo: -1138, flag: true });
|
|
814
|
-
// expect(m.format({ foo: -5, flag: true })).toBe("/-5/1");
|
|
815
|
-
// });
|
|
816
|
-
|
|
817
|
-
// it("should match built-in types with spaces", ( ) => {
|
|
818
|
-
// const m = $url.compile("/{foo: int}/{flag: bool}");
|
|
819
|
-
// expect(m.exec("/1138/1")).toEqual({ foo: 1138, flag: true });
|
|
820
|
-
// expect(m.format({ foo: 5, flag: true })).toBe("/5/1");
|
|
821
|
-
// });
|
|
822
|
-
|
|
823
|
-
// it("should match types named only in params", ( ) => {
|
|
824
|
-
// const m = $url.compile("/{foo}/{flag}", {
|
|
825
|
-
// state: {
|
|
826
|
-
// params: {
|
|
827
|
-
// foo: { type: "int" },
|
|
828
|
-
// flag: { type: "bool" },
|
|
829
|
-
// },
|
|
830
|
-
// },
|
|
831
|
-
// });
|
|
832
|
-
// expect(m.exec("/1138/1")).toEqual({ foo: 1138, flag: true });
|
|
833
|
-
// expect(m.format({ foo: 5, flag: true })).toBe("/5/1");
|
|
834
|
-
// });
|
|
835
|
-
|
|
836
|
-
// it("should throw an error if a param type is declared twice", ( ) => {
|
|
837
|
-
// expect(( ) => {
|
|
838
|
-
// $url.compile("/{foo:int}", {
|
|
839
|
-
// state: {
|
|
840
|
-
// params: {
|
|
841
|
-
// foo: { type: "int" },
|
|
842
|
-
// },
|
|
843
|
-
// },
|
|
844
|
-
// });
|
|
845
|
-
// }).toThrow(new Error("Param 'foo' has two type configurations."));
|
|
846
|
-
// });
|
|
847
|
-
|
|
848
|
-
// it("should encode/decode dates", ( ) => {
|
|
849
|
-
// const m = $url.compile("/calendar/{date:date}"),
|
|
850
|
-
// result = m.exec("/calendar/2014-03-26");
|
|
851
|
-
// const date = new Date(2014, 2, 26);
|
|
852
|
-
|
|
853
|
-
// expect(result.date instanceof Date).toBe(true);
|
|
854
|
-
// expect(result.date.toUTCString()).toEqual(date.toUTCString());
|
|
855
|
-
// expect(m.format({ date: date })).toBe("/calendar/2014-03-26");
|
|
856
|
-
// });
|
|
857
|
-
|
|
858
|
-
// it("should encode/decode arbitrary objects to json", ( ) => {
|
|
859
|
-
// const m = $url.compile("/state/{param1:json}/{param2:json}");
|
|
860
|
-
|
|
861
|
-
// const params = {
|
|
862
|
-
// param1: { foo: "huh", count: 3 },
|
|
863
|
-
// param2: { foo: "wha", count: 5 },
|
|
864
|
-
// };
|
|
865
|
-
|
|
866
|
-
// const json1 = '{"foo":"huh","count":3}';
|
|
867
|
-
// const json2 = '{"foo":"wha","count":5}';
|
|
868
|
-
|
|
869
|
-
// expect(m.format(params)).toBe(
|
|
870
|
-
// "/state/" + encodeURIComponent(json1) + "/" + encodeURIComponent(json2),
|
|
871
|
-
// );
|
|
872
|
-
// expect(m.exec("/state/" + json1 + "/" + json2)).toEqual(params);
|
|
873
|
-
// });
|
|
874
|
-
|
|
875
|
-
// it("should not match invalid typed parameter values", ( ) => {
|
|
876
|
-
// const m = $url.compile("/users/{id:int}");
|
|
877
|
-
|
|
878
|
-
// expect(m.exec("/users/1138").id).toBe(1138);
|
|
879
|
-
// expect(m.exec("/users/alpha")).toBeNull();
|
|
880
|
-
|
|
881
|
-
// expect(m.format({ id: 1138 })).toBe("/users/1138");
|
|
882
|
-
// expect(m.format({ id: "alpha" })).toBeNull();
|
|
883
|
-
// });
|
|
884
|
-
|
|
885
|
-
// it("should automatically handle multiple search param values", ( ) => {
|
|
886
|
-
// const m = $url.compile("/foo/{fooid:int}?{bar:int}");
|
|
887
|
-
|
|
888
|
-
// $url.url("/foo/5?bar=1");
|
|
889
|
-
// expect(m.exec($url.getPath(), $url.getSearch())).toEqual({ fooid: 5, bar: 1 });
|
|
890
|
-
// expect(m.format({ fooid: 5, bar: 1 })).toEqual("/foo/5?bar=1");
|
|
891
|
-
|
|
892
|
-
// $url.url("/foo/5?bar=1&bar=2&bar=3");
|
|
893
|
-
// if (Array.isArray($url.getSearch()))
|
|
894
|
-
// // conditional for angular 1.0.8
|
|
895
|
-
// expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
896
|
-
// fooid: 5,
|
|
897
|
-
// bar: [1, 2, 3],
|
|
898
|
-
// });
|
|
899
|
-
// expect(m.format({ fooid: 5, bar: [1, 2, 3] })).toEqual(
|
|
900
|
-
// "/foo/5?bar=1&bar=2&bar=3",
|
|
901
|
-
// );
|
|
902
|
-
|
|
903
|
-
// m.format();
|
|
904
|
-
// });
|
|
905
|
-
|
|
906
|
-
// it("should allow custom types to handle multiple search param values manually", ( ) => {
|
|
907
|
-
// $url.type("custArray", {
|
|
908
|
-
// encode: function (array) {
|
|
909
|
-
// return array.join("-");
|
|
910
|
-
// },
|
|
911
|
-
// decode: function (val) {
|
|
912
|
-
// return Array.isArray(val) ? val : val.split(/-/);
|
|
913
|
-
// },
|
|
914
|
-
// equals: angular.equals,
|
|
915
|
-
// is: Array.isArray,
|
|
916
|
-
// });
|
|
917
|
-
|
|
918
|
-
// const m = $url.compile("/foo?{bar:custArray}", {
|
|
919
|
-
// state: { params: { bar: { array: false } } },
|
|
920
|
-
// });
|
|
921
|
-
|
|
922
|
-
// $url.url("/foo?bar=fox");
|
|
923
|
-
// expect(m.exec($url.getPath(), $url.getSearch())).toEqual({ bar: ["fox"] });
|
|
924
|
-
// expect(m.format({ bar: ["fox"] })).toEqual("/foo?bar=fox");
|
|
925
|
-
|
|
926
|
-
// $url.url("/foo?bar=quick-brown-fox");
|
|
927
|
-
// expect(m.exec($url.getPath(), $url.getSearch())).toEqual({
|
|
928
|
-
// bar: ["quick", "brown", "fox"],
|
|
929
|
-
// });
|
|
930
|
-
// expect(m.format({ bar: ["quick", "brown", "fox"] })).toEqual(
|
|
931
|
-
// "/foo?bar=quick-brown-fox",
|
|
932
|
-
// );
|
|
933
|
-
// });
|
|
934
|
-
// });
|
|
935
|
-
|
|
936
|
-
// describe("optional parameters", ( ) => {
|
|
937
|
-
// it("should match with or without values", ( ) => {
|
|
938
|
-
// const m = $url.compile("/users/{id:int}", {
|
|
939
|
-
// state: {
|
|
940
|
-
// params: { id: { value: null, squash: true } },
|
|
941
|
-
// },
|
|
942
|
-
// });
|
|
943
|
-
// expect(m.exec("/users/1138")).toEqual({ id: 1138 });
|
|
944
|
-
// expect(m.exec("/users1138")).toBeNull();
|
|
945
|
-
// expect(m.exec("/users/").id).toBeNull();
|
|
946
|
-
// expect(m.exec("/users").id).toBeNull();
|
|
947
|
-
// });
|
|
948
|
-
|
|
949
|
-
// it("should correctly match multiple", ( ) => {
|
|
950
|
-
// const m = $url.compile("/users/{id:int}/{state:[A-Z]+}", {
|
|
951
|
-
// state: {
|
|
952
|
-
// params: {
|
|
953
|
-
// id: { value: null, squash: true },
|
|
954
|
-
// state: { value: null, squash: true },
|
|
955
|
-
// },
|
|
956
|
-
// },
|
|
957
|
-
// });
|
|
958
|
-
// expect(m.exec("/users/1138")).toEqual({ id: 1138, state: null });
|
|
959
|
-
// expect(m.exec("/users/1138/NY")).toEqual({ id: 1138, state: "NY" });
|
|
960
|
-
|
|
961
|
-
// expect(m.exec("/users/").id).toBeNull();
|
|
962
|
-
// expect(m.exec("/users/").state).toBeNull();
|
|
963
|
-
|
|
964
|
-
// expect(m.exec("/users").id).toBeNull();
|
|
965
|
-
// expect(m.exec("/users").state).toBeNull();
|
|
966
|
-
|
|
967
|
-
// expect(m.exec("/users/NY").state).toBe("NY");
|
|
968
|
-
// expect(m.exec("/users/NY").id).toBeNull();
|
|
969
|
-
// });
|
|
970
|
-
|
|
971
|
-
// it("should correctly format with or without values", ( ) => {
|
|
972
|
-
// const m = $url.compile("/users/{id:int}", {
|
|
973
|
-
// state: {
|
|
974
|
-
// params: { id: { value: null } },
|
|
975
|
-
// },
|
|
976
|
-
// });
|
|
977
|
-
// expect(m.format()).toBe("/users/");
|
|
978
|
-
// expect(m.format({ id: 1138 })).toBe("/users/1138");
|
|
979
|
-
// });
|
|
980
|
-
|
|
981
|
-
// it("should correctly format multiple", ( ) => {
|
|
982
|
-
// const m = $url.compile("/users/{id:int}/{state:[A-Z]+}", {
|
|
983
|
-
// state: {
|
|
984
|
-
// params: {
|
|
985
|
-
// id: { value: null, squash: true },
|
|
986
|
-
// state: { value: null, squash: true },
|
|
987
|
-
// },
|
|
988
|
-
// },
|
|
989
|
-
// });
|
|
990
|
-
|
|
991
|
-
// expect(m.format()).toBe("/users");
|
|
992
|
-
// expect(m.format({ id: 1138 })).toBe("/users/1138");
|
|
993
|
-
// expect(m.format({ state: "NY" })).toBe("/users/NY");
|
|
994
|
-
// expect(m.format({ id: 1138, state: "NY" })).toBe("/users/1138/NY");
|
|
995
|
-
// });
|
|
996
|
-
|
|
997
|
-
// it("should match in between static segments", ( ) => {
|
|
998
|
-
// const m = $url.compile("/users/{user:int}/photos", {
|
|
999
|
-
// state: {
|
|
1000
|
-
// params: { user: { value: 5, squash: true } },
|
|
1001
|
-
// },
|
|
1002
|
-
// });
|
|
1003
|
-
// expect(m.exec("/users/photos").user).toBe(5);
|
|
1004
|
-
// expect(m.exec("/users/6/photos").user).toBe(6);
|
|
1005
|
-
// expect(m.format()).toBe("/users/photos");
|
|
1006
|
-
// expect(m.format({ user: 1138 })).toBe("/users/1138/photos");
|
|
1007
|
-
// });
|
|
1008
|
-
|
|
1009
|
-
// it("should correctly format with an optional followed by a required parameter", ( ) => {
|
|
1010
|
-
// const m = $url.compile("/home/:user/gallery/photos/:photo", {
|
|
1011
|
-
// state: {
|
|
1012
|
-
// params: {
|
|
1013
|
-
// user: { value: null, squash: true },
|
|
1014
|
-
// photo: undefined,
|
|
1015
|
-
// },
|
|
1016
|
-
// },
|
|
1017
|
-
// });
|
|
1018
|
-
// expect(m.format({ photo: 12 })).toBe("/home/gallery/photos/12");
|
|
1019
|
-
// expect(m.format({ user: 1138, photo: 13 })).toBe(
|
|
1020
|
-
// "/home/1138/gallery/photos/13",
|
|
1021
|
-
// );
|
|
1022
|
-
// });
|
|
1023
|
-
|
|
1024
|
-
// describe("default values", ( ) => {
|
|
1025
|
-
// it("should populate if not supplied in URL", ( ) => {
|
|
1026
|
-
// const m = $url.compile("/users/{id:int}/{test}", {
|
|
1027
|
-
// state: {
|
|
1028
|
-
// params: {
|
|
1029
|
-
// id: { value: 0, squash: true },
|
|
1030
|
-
// test: { value: "foo", squash: true },
|
|
1031
|
-
// },
|
|
1032
|
-
// },
|
|
1033
|
-
// });
|
|
1034
|
-
// expect(m.exec("/users")).toEqual({ id: 0, test: "foo" });
|
|
1035
|
-
// expect(m.exec("/users/2")).toEqual({ id: 2, test: "foo" });
|
|
1036
|
-
// expect(m.exec("/users/bar")).toEqual({ id: 0, test: "bar" });
|
|
1037
|
-
// expect(m.exec("/users/2/bar")).toEqual({ id: 2, test: "bar" });
|
|
1038
|
-
// expect(m.exec("/users/bar/2")).toBeNull();
|
|
1039
|
-
// });
|
|
1040
|
-
|
|
1041
|
-
// it("should populate even if the regexp requires 1 or more chars", ( ) => {
|
|
1042
|
-
// const m = $url.compile(
|
|
1043
|
-
// "/record/{appId}/{recordId:[0-9a-fA-F]{10,24}}",
|
|
1044
|
-
// {
|
|
1045
|
-
// state: {
|
|
1046
|
-
// params: { appId: null, recordId: null },
|
|
1047
|
-
// },
|
|
1048
|
-
// },
|
|
1049
|
-
// );
|
|
1050
|
-
// expect(m.exec("/record/546a3e4dd273c60780e35df3/")).toEqual({
|
|
1051
|
-
// appId: "546a3e4dd273c60780e35df3",
|
|
1052
|
-
// recordId: null,
|
|
1053
|
-
// });
|
|
1054
|
-
// });
|
|
1055
|
-
|
|
1056
|
-
// it("should allow shorthand definitions", ( ) => {
|
|
1057
|
-
// const m = $url.compile("/foo/:foo", {
|
|
1058
|
-
// state: {
|
|
1059
|
-
// params: { foo: "bar" },
|
|
1060
|
-
// },
|
|
1061
|
-
// });
|
|
1062
|
-
// expect(m.exec("/foo/")).toEqual({ foo: "bar" });
|
|
1063
|
-
// });
|
|
1064
|
-
|
|
1065
|
-
// it("should populate query params", ( ) => {
|
|
1066
|
-
// const defaults = { order: "name", limit: 25, page: 1 };
|
|
1067
|
-
// const m = $url.compile("/foo?order&{limit:int}&{page:int}", {
|
|
1068
|
-
// state: {
|
|
1069
|
-
// params: defaults,
|
|
1070
|
-
// },
|
|
1071
|
-
// });
|
|
1072
|
-
// expect(m.exec("/foo")).toEqual(defaults);
|
|
1073
|
-
// });
|
|
1074
|
-
|
|
1075
|
-
// it("should allow function-calculated values", ( ) => {
|
|
1076
|
-
// function barFn() {
|
|
1077
|
-
// return "Value from bar()";
|
|
1078
|
-
// }
|
|
1079
|
-
// let m = $url.compile("/foo/:bar", {
|
|
1080
|
-
// state: {
|
|
1081
|
-
// params: { bar: barFn },
|
|
1082
|
-
// },
|
|
1083
|
-
// });
|
|
1084
|
-
// expect(m.exec("/foo/").bar).toBe("Value from bar()");
|
|
1085
|
-
|
|
1086
|
-
// m = $url.compile("/foo/:bar", {
|
|
1087
|
-
// state: {
|
|
1088
|
-
// params: { bar: { value: barFn, squash: true } },
|
|
1089
|
-
// },
|
|
1090
|
-
// });
|
|
1091
|
-
// expect(m.exec("/foo").bar).toBe("Value from bar()");
|
|
1092
|
-
|
|
1093
|
-
// m = $url.compile("/foo?bar", {
|
|
1094
|
-
// state: {
|
|
1095
|
-
// params: { bar: barFn },
|
|
1096
|
-
// },
|
|
1097
|
-
// });
|
|
1098
|
-
// expect(m.exec("/foo").bar).toBe("Value from bar()");
|
|
1099
|
-
// });
|
|
1100
|
-
|
|
1101
|
-
// it("should allow injectable functions", function ($stateParams) {
|
|
1102
|
-
// const m = $url.compile("/users/{user:json}", {
|
|
1103
|
-
// state: {
|
|
1104
|
-
// params: {
|
|
1105
|
-
// user: function ($stateParams) {
|
|
1106
|
-
// return $stateParams.user;
|
|
1107
|
-
// },
|
|
1108
|
-
// },
|
|
1109
|
-
// },
|
|
1110
|
-
// });
|
|
1111
|
-
// const user = { name: "Bob" };
|
|
1112
|
-
|
|
1113
|
-
// $stateParams.user = user;
|
|
1114
|
-
// expect(m.exec("/users/").user).toBe(user);
|
|
1115
|
-
// });
|
|
1116
|
-
|
|
1117
|
-
// xit("should match when used as prefix", ( ) => {
|
|
1118
|
-
// const m = $url.compile("/{lang:[a-z]{2}}/foo", {
|
|
1119
|
-
// state: {
|
|
1120
|
-
// params: { lang: "de" },
|
|
1121
|
-
// },
|
|
1122
|
-
// });
|
|
1123
|
-
// expect(m.exec("/de/foo")).toEqual({ lang: "de" });
|
|
1124
|
-
// expect(m.exec("/foo")).toEqual({ lang: "de" });
|
|
1125
|
-
// });
|
|
1126
|
-
|
|
1127
|
-
// describe("squash policy", ( ) => {
|
|
1128
|
-
// const Session = { username: "loggedinuser" };
|
|
1129
|
-
// function getMatcher(squash) {
|
|
1130
|
-
// return $url.compile(
|
|
1131
|
-
// "/user/:userid/gallery/:galleryid/photo/:photoid",
|
|
1132
|
-
// {
|
|
1133
|
-
// state: {
|
|
1134
|
-
// params: {
|
|
1135
|
-
// userid: {
|
|
1136
|
-
// squash: squash,
|
|
1137
|
-
// value: ( ) => {
|
|
1138
|
-
// return Session.username;
|
|
1139
|
-
// },
|
|
1140
|
-
// },
|
|
1141
|
-
// galleryid: { squash: squash, value: "favorites" },
|
|
1142
|
-
// },
|
|
1143
|
-
// },
|
|
1144
|
-
// },
|
|
1145
|
-
// );
|
|
1146
|
-
// }
|
|
1147
|
-
|
|
1148
|
-
// it(": true should squash the default value and one slash", function (
|
|
1149
|
-
// $stateParams,
|
|
1150
|
-
// ) {
|
|
1151
|
-
// const m = getMatcher(true);
|
|
1152
|
-
|
|
1153
|
-
// const defaultParams = {
|
|
1154
|
-
// userid: "loggedinuser",
|
|
1155
|
-
// galleryid: "favorites",
|
|
1156
|
-
// photoid: "123",
|
|
1157
|
-
// };
|
|
1158
|
-
// expect(m.exec("/user/gallery/photo/123")).toEqual(defaultParams);
|
|
1159
|
-
// expect(m.exec("/user//gallery//photo/123")).toEqual(defaultParams);
|
|
1160
|
-
// expect(m.format(defaultParams)).toBe("/user/gallery/photo/123");
|
|
1161
|
-
|
|
1162
|
-
// const nonDefaultParams = {
|
|
1163
|
-
// userid: "otheruser",
|
|
1164
|
-
// galleryid: "travel",
|
|
1165
|
-
// photoid: "987",
|
|
1166
|
-
// };
|
|
1167
|
-
// expect(m.exec("/user/otheruser/gallery/travel/photo/987")).toEqual(
|
|
1168
|
-
// nonDefaultParams,
|
|
1169
|
-
// );
|
|
1170
|
-
// expect(m.format(nonDefaultParams)).toBe(
|
|
1171
|
-
// "/user/otheruser/gallery/travel/photo/987",
|
|
1172
|
-
// );
|
|
1173
|
-
// });
|
|
1174
|
-
|
|
1175
|
-
// it(": false should not squash default values", function (
|
|
1176
|
-
// $stateParams,
|
|
1177
|
-
// ) {
|
|
1178
|
-
// const m = getMatcher(false);
|
|
1179
|
-
|
|
1180
|
-
// const defaultParams = {
|
|
1181
|
-
// userid: "loggedinuser",
|
|
1182
|
-
// galleryid: "favorites",
|
|
1183
|
-
// photoid: "123",
|
|
1184
|
-
// };
|
|
1185
|
-
// expect(
|
|
1186
|
-
// m.exec("/user/loggedinuser/gallery/favorites/photo/123"),
|
|
1187
|
-
// ).toEqual(defaultParams);
|
|
1188
|
-
// expect(m.format(defaultParams)).toBe(
|
|
1189
|
-
// "/user/loggedinuser/gallery/favorites/photo/123",
|
|
1190
|
-
// );
|
|
1191
|
-
|
|
1192
|
-
// const nonDefaultParams = {
|
|
1193
|
-
// userid: "otheruser",
|
|
1194
|
-
// galleryid: "travel",
|
|
1195
|
-
// photoid: "987",
|
|
1196
|
-
// };
|
|
1197
|
-
// expect(m.exec("/user/otheruser/gallery/travel/photo/987")).toEqual(
|
|
1198
|
-
// nonDefaultParams,
|
|
1199
|
-
// );
|
|
1200
|
-
// expect(m.format(nonDefaultParams)).toBe(
|
|
1201
|
-
// "/user/otheruser/gallery/travel/photo/987",
|
|
1202
|
-
// );
|
|
1203
|
-
// });
|
|
1204
|
-
|
|
1205
|
-
// it(": '' should squash the default value to an empty string", function (
|
|
1206
|
-
// $stateParams,
|
|
1207
|
-
// ) {
|
|
1208
|
-
// const m = getMatcher("");
|
|
1209
|
-
|
|
1210
|
-
// const defaultParams = {
|
|
1211
|
-
// userid: "loggedinuser",
|
|
1212
|
-
// galleryid: "favorites",
|
|
1213
|
-
// photoid: "123",
|
|
1214
|
-
// };
|
|
1215
|
-
// expect(m.exec("/user//gallery//photo/123")).toEqual(defaultParams);
|
|
1216
|
-
// expect(m.format(defaultParams)).toBe("/user//gallery//photo/123");
|
|
1217
|
-
|
|
1218
|
-
// const nonDefaultParams = {
|
|
1219
|
-
// userid: "otheruser",
|
|
1220
|
-
// galleryid: "travel",
|
|
1221
|
-
// photoid: "987",
|
|
1222
|
-
// };
|
|
1223
|
-
// expect(m.exec("/user/otheruser/gallery/travel/photo/987")).toEqual(
|
|
1224
|
-
// nonDefaultParams,
|
|
1225
|
-
// );
|
|
1226
|
-
// expect(m.format(nonDefaultParams)).toBe(
|
|
1227
|
-
// "/user/otheruser/gallery/travel/photo/987",
|
|
1228
|
-
// );
|
|
1229
|
-
// });
|
|
1230
|
-
|
|
1231
|
-
// it(": '~' should squash the default value and replace it with '~'", function (
|
|
1232
|
-
// $stateParams,
|
|
1233
|
-
// ) {
|
|
1234
|
-
// const m = getMatcher("~");
|
|
1235
|
-
|
|
1236
|
-
// const defaultParams = {
|
|
1237
|
-
// userid: "loggedinuser",
|
|
1238
|
-
// galleryid: "favorites",
|
|
1239
|
-
// photoid: "123",
|
|
1240
|
-
// };
|
|
1241
|
-
// expect(m.exec("/user//gallery//photo/123")).toEqual(defaultParams);
|
|
1242
|
-
// expect(m.exec("/user/~/gallery/~/photo/123")).toEqual(defaultParams);
|
|
1243
|
-
// expect(m.format(defaultParams)).toBe("/user/~/gallery/~/photo/123");
|
|
1244
|
-
|
|
1245
|
-
// const nonDefaultParams = {
|
|
1246
|
-
// userid: "otheruser",
|
|
1247
|
-
// galleryid: "travel",
|
|
1248
|
-
// photoid: "987",
|
|
1249
|
-
// };
|
|
1250
|
-
// expect(m.exec("/user/otheruser/gallery/travel/photo/987")).toEqual(
|
|
1251
|
-
// nonDefaultParams,
|
|
1252
|
-
// );
|
|
1253
|
-
// expect(m.format(nonDefaultParams)).toBe(
|
|
1254
|
-
// "/user/otheruser/gallery/travel/photo/987",
|
|
1255
|
-
// );
|
|
1256
|
-
// });
|
|
1257
|
-
// });
|
|
1258
|
-
// });
|
|
1259
|
-
// });
|
|
1260
|
-
|
|
1261
|
-
// describe("strict matching", ( ) => {
|
|
1262
|
-
// it("should match with or without trailing slash", ( ) => {
|
|
1263
|
-
// const m = $url.compile("/users", { strict: false });
|
|
1264
|
-
// expect(m.exec("/users")).toEqual({});
|
|
1265
|
-
// expect(m.exec("/users/")).toEqual({});
|
|
1266
|
-
// });
|
|
1267
|
-
|
|
1268
|
-
// it("should not match multiple trailing slashes", ( ) => {
|
|
1269
|
-
// const m = $url.compile("/users", { strict: false });
|
|
1270
|
-
// expect(m.exec("/users//")).toBeNull();
|
|
1271
|
-
// });
|
|
1272
|
-
|
|
1273
|
-
// it("should match when defined with parameters", ( ) => {
|
|
1274
|
-
// const m = $url.compile("/users/{name}", {
|
|
1275
|
-
// strict: false,
|
|
1276
|
-
// state: {
|
|
1277
|
-
// params: {
|
|
1278
|
-
// name: { value: null },
|
|
1279
|
-
// },
|
|
1280
|
-
// },
|
|
1281
|
-
// });
|
|
1282
|
-
// expect(m.exec("/users/")).toEqual({ name: null });
|
|
1283
|
-
// expect(m.exec("/users/bob")).toEqual({ name: "bob" });
|
|
1284
|
-
// expect(m.exec("/users/bob/")).toEqual({ name: "bob" });
|
|
1285
|
-
// expect(m.exec("/users/bob//")).toBeNull();
|
|
1286
|
-
// });
|
|
1287
|
-
// });
|
|
1288
|
-
// });
|