@angular-wave/angular.ts 0.7.7 → 0.8.0
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/animations/raf-scheduler.d.ts +2 -2
- package/@types/animations/shared.d.ts +0 -1
- package/@types/core/compile/attributes.d.ts +3 -3
- package/@types/core/compile/compile.d.ts +1 -1
- package/@types/core/di/injector.d.ts +0 -1
- package/@types/core/di/internal-injector.d.ts +1 -0
- package/@types/core/di/ng-module.d.ts +5 -0
- package/@types/core/filter/filter.d.ts +11 -13
- package/@types/core/parse/parse.d.ts +6 -7
- package/@types/core/sanitize/sanitize-uri.d.ts +3 -6
- package/@types/core/scope/scope.d.ts +1 -1
- package/@types/directive/attrs/attrs.d.ts +7 -1
- package/@types/directive/bind/bind.d.ts +2 -1
- package/@types/directive/events/events.d.ts +9 -3
- package/@types/directive/http/http.d.ts +6 -2
- package/@types/directive/include/include.d.ts +2 -2
- package/@types/directive/input/input.d.ts +2 -12
- package/@types/directive/messages/messages.d.ts +9 -48
- package/@types/directive/model/model.d.ts +3 -3
- package/@types/directive/options/options.d.ts +13 -20
- package/@types/directive/switch/switch.d.ts +1 -0
- package/@types/directive/transclude/transclude.d.ts +10 -6
- package/@types/index.d.ts +1 -1
- package/@types/interface.d.ts +56 -18
- package/@types/{public.d.ts → ng.d.ts} +2 -2
- package/@types/router/directives/view-directive.d.ts +2 -19
- package/@types/router/{common → glob}/glob.d.ts +5 -1
- package/@types/router/globals.d.ts +2 -3
- package/@types/router/path/path-utils.d.ts +8 -11
- package/@types/router/state/interface.d.ts +1 -1
- package/@types/router/state/state-object.d.ts +1 -1
- package/@types/router/state/state-registry.d.ts +1 -2
- package/@types/router/state/state-service.d.ts +8 -7
- package/@types/router/state-filters.d.ts +24 -2
- package/@types/router/transition/transition.d.ts +12 -15
- package/@types/router/url/url-matcher.d.ts +3 -3
- package/@types/router/url/url-rule.d.ts +1 -0
- package/@types/router/url/url-rules.d.ts +26 -6
- package/@types/router/url/url-service.d.ts +30 -42
- package/@types/services/anchor-scroll.d.ts +1 -1
- package/@types/{core → services/exception}/exception-handler.d.ts +4 -4
- package/@types/{core/error-handler.d.ts → services/exception/interface.d.ts} +1 -1
- package/@types/services/http/http.d.ts +48 -3
- package/@types/services/http/interface.d.ts +2 -2
- package/@types/services/http-backend/http-backend.d.ts +49 -44
- package/@types/services/location/interface.d.ts +63 -0
- package/@types/services/location/location.d.ts +330 -0
- package/@types/{core → services}/sce/sce.d.ts +1 -1
- package/@types/services/template-cache/interface.d.ts +8 -2
- package/@types/services/template-cache/template-cache.d.ts +1 -1
- package/@types/services/template-request.d.ts +1 -1
- package/@types/shared/cache.d.ts +0 -2
- package/@types/shared/common.d.ts +0 -2
- package/@types/shared/dom.d.ts +6 -0
- package/@types/shared/interface.d.ts +0 -4
- package/@types/{router/common → shared}/queue.d.ts +2 -2
- package/@types/shared/test-utils.d.ts +1 -0
- package/@types/shared/url-utils/interface.d.ts +46 -0
- package/@types/shared/url-utils/url-utils.d.ts +64 -0
- package/@types/shared/utils.d.ts +44 -6
- package/Makefile +8 -4
- package/dist/angular-ts.esm.js +1889 -2199
- package/dist/angular-ts.umd.js +1889 -2199
- package/dist/angular-ts.umd.min.js +1 -1
- package/docs/assets/scss/index.scss +23 -0
- package/docs/content/_index.md +9 -8
- package/docs/content/docs/_index.md +1 -1
- package/docs/content/docs/directive/app.md +1 -1
- package/docs/content/docs/directive/bind.md +10 -8
- package/docs/content/docs/directive/blur.md +1 -1
- package/docs/content/docs/directive/channel.md +2 -2
- package/docs/content/docs/directive/class-even.md +1 -1
- package/docs/content/docs/directive/class-odd.md +1 -1
- package/docs/content/docs/directive/class.md +1 -1
- package/docs/content/docs/directive/click.md +1 -1
- package/docs/content/docs/directive/copy.md +1 -1
- package/docs/content/docs/directive/cut.md +1 -1
- package/docs/content/docs/directive/dblclick.md +1 -1
- package/docs/content/docs/directive/focus.md +1 -1
- package/docs/content/docs/directive/get.md +203 -0
- package/docs/content/docs/directive/keydown.md +1 -1
- package/docs/content/docs/directive/keyup.md +1 -1
- package/docs/content/docs/directive/load.md +1 -1
- package/docs/content/docs/directive/mousedown.md +1 -1
- package/docs/content/docs/directive/mouseenter.md +1 -1
- package/docs/content/docs/directive/mouseleave.md +1 -1
- package/docs/content/docs/directive/mousemove.md +1 -1
- package/docs/content/docs/directive/mouseout.md +1 -1
- package/docs/content/docs/directive/mouseover.md +1 -1
- package/docs/content/docs/directive/mouseup.md +1 -1
- package/docs/content/docs/directive/non-bindable.md +28 -0
- package/docs/content/docs/provider/locationProvider.md +26 -0
- package/docs/content/docs/provider/templateCacheProvider.md +66 -1
- package/docs/content/docs/service/location.md +57 -0
- package/docs/content/docs/service/templateCache.md +2 -2
- package/docs/content/docs/service/url.md +5 -0
- package/docs/layouts/partials/hooks/head-end.html +1 -1
- package/docs/layouts/shortcodes/showcss.html +2 -0
- package/docs/layouts/shortcodes/version.html +1 -0
- package/docs/static/examples/counter/counter-test.html +0 -4
- package/docs/static/examples/eventbus/eventbus-test.html +0 -4
- package/docs/static/examples/ng-bind/ng-bind.html +2 -2
- package/docs/static/examples/ng-non-bindable/ng-non-bindable-test.html +13 -0
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.html +3 -0
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.test.js +11 -0
- package/docs/static/typedoc/assets/hierarchy.js +1 -1
- package/docs/static/typedoc/assets/highlight.css +6 -6
- package/docs/static/typedoc/assets/navigation.js +1 -1
- package/docs/static/typedoc/assets/search.js +1 -1
- package/docs/static/typedoc/classes/Location.html +55 -0
- package/docs/static/typedoc/classes/LocationProvider.html +20 -0
- package/docs/static/typedoc/classes/NgModule.html +32 -0
- package/docs/static/typedoc/classes/TemplateCacheProvider.html +1 -1
- package/docs/static/typedoc/hierarchy.html +1 -1
- package/docs/static/typedoc/index.html +1 -1
- package/docs/static/typedoc/interfaces/DefaultPorts.html +5 -0
- package/docs/static/typedoc/interfaces/Directive.html +5 -4
- package/docs/static/typedoc/interfaces/Html5Mode.html +23 -0
- package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +1 -1
- package/docs/static/typedoc/interfaces/HttpResponse.html +2 -3
- package/docs/static/typedoc/interfaces/Provider.html +16 -10
- package/docs/static/typedoc/interfaces/RequestConfig.html +1 -1
- package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +1 -1
- package/docs/static/typedoc/interfaces/TemplateCache.html +7 -0
- package/docs/static/typedoc/interfaces/UrlParts.html +9 -0
- package/docs/static/typedoc/types/AnnotatedDirectiveFactory.html +1 -0
- package/docs/static/typedoc/types/AnnotatedFactory.html +1 -1
- package/docs/static/typedoc/types/DirectiveFactory.html +1 -2
- package/docs/static/typedoc/types/DirectiveFactoryFn.html +1 -0
- package/docs/static/typedoc/types/Expression.html +1 -1
- package/docs/static/typedoc/types/HttpResponseStatus.html +1 -0
- package/docs/static/typedoc/types/{TemplateCache.html → SwapModeType.html} +1 -1
- package/docs/static/typedoc/types/UrlChangeListener.html +5 -0
- package/docs/static/typedoc/variables/SwapMode.html +11 -0
- package/docs/static/version.js +13 -0
- package/docs/test-results/.last-run.json +4 -0
- package/docs/test-results/static-examples-counter-counter-counter-example/error-context.md +50 -0
- package/legacy.d.ts +0 -10
- package/package.json +1 -3
- package/src/{loader.js → angular.js} +5 -10
- package/src/angular.spec.js +189 -21
- package/src/animations/animate-children-directive.js +2 -2
- package/src/animations/animate-css.js +17 -18
- package/src/animations/animate.spec.js +1 -1
- package/src/animations/raf-scheduler.js +1 -1
- package/src/animations/shared.js +2 -12
- package/src/binding.spec.js +1 -1
- package/src/core/compile/attributes.js +1 -1
- package/src/core/compile/compile.js +7 -10
- package/src/core/compile/compile.spec.js +1 -1
- package/src/core/controller/controller.spec.js +1 -1
- package/src/core/controller/controller.test.js +1 -0
- package/src/core/di/injector.js +11 -25
- package/src/core/di/injector.spec.js +2 -2
- package/src/core/di/injector.test.js +2 -2
- package/src/core/di/internal-injector.js +7 -7
- package/src/core/di/ng-module.js +12 -27
- package/src/core/filter/filter.js +28 -28
- package/src/core/filter/filter.spec.js +1 -1
- package/src/core/filter/filter.test.js +1 -0
- package/src/core/interpolate/interpolate.js +4 -6
- package/src/core/interpolate/interpolate.spec.js +1 -1
- package/src/core/interpolate/interpolate.test.js +1 -0
- package/src/core/parse/ast/ast.spec.js +1 -1
- package/src/core/parse/ast/ast.test.js +1 -1
- package/src/core/parse/interpreter.js +32 -38
- package/src/core/parse/lexer/lexer.spec.js +1 -1
- package/src/core/parse/parse.js +150 -146
- package/src/core/parse/parse.spec.js +17 -16
- package/src/core/prop.spec.js +1 -1
- package/src/core/root-element.spec.js +1 -1
- package/src/core/sanitize/sanitize-uri.js +3 -3
- package/src/core/scope/scope.js +12 -13
- package/src/core/scope/scope.spec.js +3 -4
- package/src/directive/aria/aria.spec.js +1 -1
- package/src/directive/aria/aria.test.js +1 -0
- package/src/directive/attrs/attrs.js +7 -4
- package/src/directive/attrs/attrs.spec.js +1 -1
- package/src/directive/attrs/attrs.test.js +1 -0
- package/src/directive/attrs/boolean.spec.js +1 -1
- package/src/directive/attrs/boolean.test.js +1 -0
- package/src/directive/attrs/element-style.spec.js +1 -1
- package/src/directive/attrs/element-style.test.js +1 -0
- package/src/directive/attrs/src.spec.js +1 -1
- package/src/directive/attrs/src.test.js +1 -0
- package/src/directive/bind/bind-html.spec.js +1 -1
- package/src/directive/bind/bind.js +1 -0
- package/src/directive/bind/bind.spec.js +1 -1
- package/src/directive/bind/bind.test.js +1 -0
- package/src/directive/channel/channel.spec.js +1 -1
- package/src/directive/channel/channel.test.js +1 -0
- package/src/directive/class/class.spec.js +1 -1
- package/src/directive/class/class.test.js +1 -0
- package/src/directive/cloak/cloak.spec.js +1 -1
- package/src/directive/cloak/cloak.test.js +1 -0
- package/src/directive/controller/controller.spec.js +1 -1
- package/src/directive/controller/controller.test.js +1 -0
- package/src/directive/events/click.spec.js +1 -1
- package/src/directive/events/event.spec.js +1 -1
- package/src/directive/events/events.js +6 -2
- package/src/directive/events/events.test.js +1 -0
- package/src/directive/form/form.js +8 -5
- package/src/directive/form/form.spec.js +1 -1
- package/src/directive/form/form.test.js +1 -0
- package/src/directive/http/delete.spec.js +3 -1
- package/src/directive/http/form-test.html +18 -0
- package/src/directive/http/get.spec.js +281 -4
- package/src/directive/http/http.js +112 -15
- package/src/directive/http/http.test.js +2 -2
- package/src/directive/http/post.spec.js +506 -9
- package/src/directive/http/put.spec.js +3 -1
- package/src/directive/if/if.spec.js +1 -1
- package/src/directive/include/include.js +7 -7
- package/src/directive/include/include.spec.js +1 -1
- package/src/directive/init/init.spec.js +1 -1
- package/src/directive/init/init.test.js +1 -0
- package/src/directive/input/input.js +19 -43
- package/src/directive/input/input.spec.js +1 -2
- package/src/directive/input/input.test.js +1 -0
- package/src/directive/messages/messages.js +4 -0
- package/src/directive/messages/messages.spec.js +1 -1
- package/src/directive/messages/messages.test.js +1 -0
- package/src/directive/model/model.js +14 -14
- package/src/directive/model/model.spec.js +1 -1
- package/src/directive/model/model.test.js +1 -0
- package/src/directive/model-options/model-option.test.js +1 -0
- package/src/directive/model-options/model-options.js +1 -1
- package/src/directive/model-options/model-options.spec.js +1 -1
- package/src/directive/non-bindable/non-bindable.spec.js +1 -1
- package/src/directive/non-bindable/non-bindable.test.js +1 -0
- package/src/directive/observe/observe.spec.js +1 -1
- package/src/directive/observe/observe.test.js +1 -0
- package/src/directive/on/on.spec.js +1 -1
- package/src/directive/on/on.test.js +1 -0
- package/src/directive/options/options.js +454 -464
- package/src/directive/options/options.spec.js +1 -1
- package/src/directive/options/options.test.js +1 -0
- package/src/directive/ref/href.spec.js +1 -1
- package/src/directive/ref/href.test.js +2 -0
- package/src/directive/ref/ref.spec.js +1 -1
- package/src/directive/repeat/repeat.spec.js +2 -3
- package/src/directive/repeat/repeat.test.js +1 -0
- package/src/directive/script/script.spec.js +1 -1
- package/src/directive/script/script.test.js +1 -0
- package/src/directive/select/select.js +1 -1
- package/src/directive/select/select.spec.js +1 -1
- package/src/directive/select/select.test.js +1 -0
- package/src/directive/setter/setter.js +12 -14
- package/src/directive/setter/setter.spec.js +40 -17
- package/src/directive/setter/setter.test.js +1 -0
- package/src/directive/show-hide/show-hide.spec.js +1 -1
- package/src/directive/show-hide/show-hide.test.js +1 -0
- package/src/directive/style/style.spec.js +1 -1
- package/src/directive/style/style.test.js +1 -0
- package/src/directive/switch/switch.js +1 -0
- package/src/directive/switch/switch.spec.js +1 -1
- package/src/directive/switch/switch.test.js +1 -0
- package/src/directive/transclude/transclude.js +87 -89
- package/src/directive/validators/validators.js +82 -84
- package/src/directive/validators/validators.spec.js +5 -4
- package/src/directive/validators/validators.test.js +1 -0
- package/src/filters/filter.spec.js +1 -1
- package/src/filters/filters.spec.js +1 -1
- package/src/filters/limit-to.js +2 -3
- package/src/filters/limit-to.spec.js +1 -1
- package/src/filters/order-by.spec.js +1 -1
- package/src/index.js +1 -1
- package/src/injection-tokens.js +6 -2
- package/src/interface.ts +70 -19
- package/src/loader.md +0 -155
- package/src/{public.js → ng.js} +16 -23
- package/src/{public.spec.js → ng.spec.js} +1 -1
- package/src/router/directives/state-directives.spec.js +9 -8
- package/src/router/directives/view-directive.js +11 -9
- package/src/router/directives/view-directive.spec.js +8 -9
- package/src/router/{common/common.html → glob/glob.html} +2 -3
- package/src/router/{common → glob}/glob.js +5 -0
- package/src/router/{common/common.test.js → glob/glob.test.js} +2 -1
- package/src/router/globals.js +1 -2
- package/src/router/path/path-utils.js +5 -0
- package/src/router/router-test-hashbang.html +45 -0
- package/src/router/services.spec.js +5 -6
- package/src/router/state/interface.ts +1 -1
- package/src/router/state/state-builder.js +3 -3
- package/src/router/state/state-builder.spec.js +1 -1
- package/src/router/state/state-object.js +1 -1
- package/src/router/state/state-registry.js +2 -3
- package/src/router/state/state-service.js +13 -10
- package/src/router/state/state.spec.js +23 -22
- package/src/router/state/state.test.js +1 -0
- package/src/router/state/views.js +1 -1
- package/src/router/state-filter.spec.js +1 -1
- package/src/router/state-filters.js +15 -11
- package/src/router/template-factory.js +5 -4
- package/src/router/template-factory.spec.js +1 -1
- package/src/router/transition/hook-registry.js +1 -1
- package/src/router/transition/transition-service.js +6 -5
- package/src/router/transition/transition.js +4 -4
- package/src/router/url/url-matcher.js +3 -3
- package/src/router/url/url-rule.js +1 -0
- package/src/router/url/url-rules.js +8 -5
- package/src/router/url/url-service.js +82 -85
- package/src/router/url/url-service.spec.js +55 -39
- package/src/router/url/url.test.js +1 -0
- package/src/router/view/view.js +4 -5
- package/src/router/view/view.spec.js +10 -12
- package/src/router/view/view.test.js +1 -0
- package/src/router/view-hook.spec.js +1 -1
- package/src/router/view-scroll.spec.js +1 -1
- package/src/services/anchor-scroll.html +2 -9
- package/src/services/anchor-scroll.js +6 -5
- package/src/{core → services/exception}/exception-handler.js +2 -2
- package/src/{core/error-handler.ts → services/exception/interface.ts} +1 -1
- package/src/services/http/http.js +11 -17
- package/src/services/http/http.spec.js +2 -7
- package/src/services/http/interface.ts +2 -2
- package/src/services/http/template-request.spec.js +1 -1
- package/src/services/http-backend/http-backend.js +53 -89
- package/src/services/http-backend/http-backend.spec.js +2 -6
- package/src/services/http-backend/http-backend.test.js +1 -0
- package/src/services/location/interface.ts +70 -0
- package/src/{core → services}/location/location.html +4 -1
- package/src/services/location/location.js +999 -0
- package/src/{core → services}/location/location.spec.js +911 -532
- package/src/{core → services}/location/location.test.js +2 -2
- package/src/services/log/log.spec.js +1 -1
- package/src/services/log/log.test.js +1 -0
- package/src/services/pubsub/pubsub.spec.js +1 -1
- package/src/{core → services}/sce/sce.html +1 -1
- package/src/{core → services}/sce/sce.js +14 -10
- package/src/{core → services}/sce/sce.md +2 -2
- package/src/{core → services}/sce/sce.spec.js +3 -4
- package/src/{core → services}/sce/sce.test.js +1 -1
- package/src/services/template-cache/interface.ts +8 -2
- package/src/services/template-cache/template-cache.js +3 -1
- package/src/services/template-cache/template-cache.spec.js +73 -1
- package/src/services/template-cache/template-cache.test.js +1 -0
- package/src/services/template-request.js +2 -1
- package/src/shared/cache.js +0 -2
- package/src/shared/common.js +0 -5
- package/src/shared/common.spec.js +1 -1
- package/src/shared/dom.js +10 -0
- package/src/shared/interface.ts +0 -4
- package/src/{router/common → shared}/queue.js +7 -7
- package/src/shared/shared.html +1 -0
- package/src/shared/shared.test.js +1 -0
- package/src/shared/test-utils.js +1 -0
- package/src/shared/url-utils/interface.ts +54 -0
- package/src/{core → shared}/url-utils/url-utils.html +4 -1
- package/src/{core → shared}/url-utils/url-utils.js +26 -47
- package/src/{core → shared}/url-utils/url-utils.spec.js +10 -17
- package/src/{core → shared}/url-utils/url-utils.test.js +1 -1
- package/src/shared/utils.js +60 -9
- package/src/shared/utils.spec.js +35 -1
- package/src/src.html +1 -2
- package/typedoc.json +0 -1
- package/utils/express.js +36 -2
- package/utils/version.cjs +23 -0
- package/@types/core/location/location.d.ts +0 -317
- package/@types/core/task-tracker-factory.d.ts +0 -76
- package/@types/core/url-utils/url-utils.d.ts +0 -56
- package/@types/router/state-provider.d.ts +0 -123
- package/@types/services/browser.d.ts +0 -101
- package/docs/static/typedoc/types/SwapInsertPosition.html +0 -2
- package/jsdoc.json +0 -22
- package/src/core/location/location.js +0 -984
- package/src/core/location/location.md +0 -114
- package/src/core/task-tracker-factory.js +0 -145
- package/src/core/url-utils/url-utils.md +0 -46
- package/src/directive/non-bindable/non-bindable.md +0 -17
- package/src/loader.spec.js +0 -169
- package/src/router/state-provider.js +0 -146
- package/src/services/browser.js +0 -212
- /package/@types/{loader.d.ts → angular.d.ts} +0 -0
- /package/src/router/{common → glob}/glob.spec.js +0 -0
- /package/src/{router/common → shared}/queue.spec.js +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { test, expect } from "@playwright/test";
|
|
2
2
|
|
|
3
|
-
const TEST_URL = "src/
|
|
3
|
+
const TEST_URL = "src/services/location/location.html?random=false";
|
|
4
4
|
|
|
5
5
|
test("unit tests contain no errors", async ({ page }) => {
|
|
6
6
|
await page.goto(TEST_URL);
|
|
7
7
|
await page.content();
|
|
8
|
-
await page.waitForTimeout(
|
|
8
|
+
await page.waitForTimeout(1000);
|
|
9
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
10
10
|
/0 failures/,
|
|
11
11
|
);
|
|
@@ -5,6 +5,7 @@ const TEST_URL = "src/services/log/log.html?random=false";
|
|
|
5
5
|
test("unit tests contain no errors", async ({ page }) => {
|
|
6
6
|
await page.goto(TEST_URL);
|
|
7
7
|
await page.content();
|
|
8
|
+
await page.waitForTimeout(1000);
|
|
8
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
10
|
/0 failures/,
|
|
10
11
|
);
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<script src="/jasmine/jasmine-html.js"></script>
|
|
12
12
|
<script src="/jasmine/boot0.js"></script>
|
|
13
13
|
<script src="/jasmine/boot1.js"></script>
|
|
14
|
-
<script type="module" src="/src/
|
|
14
|
+
<script type="module" src="/src/services/sce/sce.spec.js"></script>
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="app"></div>
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
urlIsSameOrigin,
|
|
3
3
|
urlIsSameOriginAsBaseUrl,
|
|
4
4
|
urlResolve,
|
|
5
|
-
} from "
|
|
5
|
+
} from "../../shared/url-utils/url-utils.js";
|
|
6
6
|
import {
|
|
7
7
|
hasOwn,
|
|
8
8
|
isFunction,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
|
|
17
17
|
import { snakeToCamel } from "../../shared/dom.js";
|
|
18
18
|
|
|
19
|
-
/** @typedef {import("../
|
|
19
|
+
/** @typedef {import("../exception/interface.ts").Interface } ErrorHandler */
|
|
20
20
|
|
|
21
21
|
const $sceMinErr = minErr("$sce");
|
|
22
22
|
|
|
@@ -72,6 +72,7 @@ export function adjustMatcher(matcher) {
|
|
|
72
72
|
.replace(/\\\*/g, "[^:/.?&;]*");
|
|
73
73
|
return new RegExp(`^${matcher}$`);
|
|
74
74
|
}
|
|
75
|
+
|
|
75
76
|
if (isRegExp(matcher)) {
|
|
76
77
|
// The only other type of matcher allowed is a Regexp.
|
|
77
78
|
// Match entire URL / disallow partial matches.
|
|
@@ -326,13 +327,17 @@ export class SceDelegateProvider {
|
|
|
326
327
|
"Attempting to use an unsafe value in a safe context.",
|
|
327
328
|
),
|
|
328
329
|
);
|
|
329
|
-
return;
|
|
330
330
|
};
|
|
331
331
|
|
|
332
332
|
if ($injector.has("$sanitize")) {
|
|
333
333
|
htmlSanitizer = $injector.get("$sanitize");
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
/**
|
|
337
|
+
* @param {string|RegExp} matcher
|
|
338
|
+
* @param {import("../../shared/url-utils/interface").ParsedUrl} parsedUrl
|
|
339
|
+
* @return {boolean}
|
|
340
|
+
*/
|
|
336
341
|
function matchUrl(matcher, parsedUrl) {
|
|
337
342
|
if (matcher === "self") {
|
|
338
343
|
return (
|
|
@@ -340,7 +345,7 @@ export class SceDelegateProvider {
|
|
|
340
345
|
);
|
|
341
346
|
}
|
|
342
347
|
// definitely a regex. See adjustMatchers()
|
|
343
|
-
return !!matcher.exec(parsedUrl.href);
|
|
348
|
+
return !!(/** @type {RegExp} */ (matcher).exec(parsedUrl.href));
|
|
344
349
|
}
|
|
345
350
|
|
|
346
351
|
function isResourceUrlAllowedByPolicy(url) {
|
|
@@ -556,7 +561,6 @@ export class SceDelegateProvider {
|
|
|
556
561
|
"Attempting to use an unsafe value in a safe context.",
|
|
557
562
|
),
|
|
558
563
|
);
|
|
559
|
-
return;
|
|
560
564
|
}
|
|
561
565
|
|
|
562
566
|
return { trustAs, getTrusted, valueOf };
|
|
@@ -755,7 +759,7 @@ export function SceProvider() {
|
|
|
755
759
|
|
|
756
760
|
/**
|
|
757
761
|
* Shorthand method. `$sce.parseAsHtml(expression string)` →
|
|
758
|
-
* {@link ng.$
|
|
762
|
+
* {@link ng.$sceparseAs `$sce.parseAs($sce.HTML, value)`}
|
|
759
763
|
*
|
|
760
764
|
* @param {string} expression String expression to compile.
|
|
761
765
|
* @return {function(context, locals)} A function which represents the compiled expression:
|
|
@@ -768,7 +772,7 @@ export function SceProvider() {
|
|
|
768
772
|
|
|
769
773
|
/**
|
|
770
774
|
* Shorthand method. `$sce.parseAsCss(value)` →
|
|
771
|
-
* {@link ng.$
|
|
775
|
+
* {@link ng.$sceparseAs `$sce.parseAs($sce.CSS, value)`}
|
|
772
776
|
*
|
|
773
777
|
* @param {string} expression String expression to compile.
|
|
774
778
|
* @return {function(context, locals)} A function which represents the compiled expression:
|
|
@@ -781,7 +785,7 @@ export function SceProvider() {
|
|
|
781
785
|
|
|
782
786
|
/**
|
|
783
787
|
* Shorthand method. `$sce.parseAsUrl(value)` →
|
|
784
|
-
* {@link ng.$
|
|
788
|
+
* {@link ng.$sceparseAs `$sce.parseAs($sce.URL, value)`}
|
|
785
789
|
*
|
|
786
790
|
* @param {string} expression String expression to compile.
|
|
787
791
|
* @return {function(context, locals)} A function which represents the compiled expression:
|
|
@@ -794,7 +798,7 @@ export function SceProvider() {
|
|
|
794
798
|
|
|
795
799
|
/**
|
|
796
800
|
* Shorthand method. `$sce.parseAsResourceUrl(value)` →
|
|
797
|
-
* {@link ng.$
|
|
801
|
+
* {@link ng.$sceparseAs `$sce.parseAs($sce.RESOURCE_URL, value)`}
|
|
798
802
|
*
|
|
799
803
|
* @param {string} expression String expression to compile.
|
|
800
804
|
* @return {function(context, locals)} A function which represents the compiled expression:
|
|
@@ -807,7 +811,7 @@ export function SceProvider() {
|
|
|
807
811
|
|
|
808
812
|
/**
|
|
809
813
|
* Shorthand method. `$sce.parseAsJs(value)` →
|
|
810
|
-
* {@link ng.$
|
|
814
|
+
* {@link ng.$sceparseAs `$sce.parseAs($sce.JS, value)`}
|
|
811
815
|
*
|
|
812
816
|
* @param {string} expression String expression to compile.
|
|
813
817
|
* @return {function(context, locals)} A function which represents the compiled expression:
|
|
@@ -82,13 +82,13 @@
|
|
|
82
82
|
- In privileged contexts, directives and code will bind to the result of {@link ng.$sce#getTrusted
|
|
83
83
|
- $sce.getTrusted(context, value)} rather than to the value directly. Think of this function as
|
|
84
84
|
- a way to enforce the required security context in your data sink. Directives use {@link
|
|
85
|
-
- ng.$
|
|
85
|
+
- ng.$sceparseAs $sce.parseAs} rather than `$parse` to watch attribute bindings, which performs
|
|
86
86
|
- the {@link ng.$sce#getTrusted $sce.getTrusted} behind the scenes on non-constant literals. Also,
|
|
87
87
|
- when binding without directives, AngularTS will understand the context of your bindings
|
|
88
88
|
- automatically.
|
|
89
89
|
-
|
|
90
90
|
- As an example, {@link ng.directive:ngBindHtml ngBindHtml} uses {@link
|
|
91
|
-
- ng.$
|
|
91
|
+
- ng.$sceparseAsHtml $sce.parseAsHtml(binding expression)}. Here's the actual code (slightly
|
|
92
92
|
- simplified):
|
|
93
93
|
-
|
|
94
94
|
- ```
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { createInjector } from "
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { adjustMatcher } from "./sce";
|
|
1
|
+
import { createInjector } from "../../core/di/injector.js";
|
|
2
|
+
import { Angular } from "../../angular.js";
|
|
3
|
+
import { adjustMatcher } from "./sce.js";
|
|
5
4
|
import { wait } from "../../shared/test-utils.js";
|
|
6
5
|
|
|
7
6
|
describe("SCE", () => {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A cache for mapping template
|
|
2
|
+
* A cache interface for mapping template urls to their XHR responses.
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export interface TemplateCache {
|
|
5
|
+
get(key: string): any | undefined;
|
|
6
|
+
set(key: string, value: any): this;
|
|
7
|
+
has(key: string): boolean;
|
|
8
|
+
delete(key: string): boolean;
|
|
9
|
+
clear(): void;
|
|
10
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Angular } from "../../
|
|
1
|
+
import { Angular } from "../../angular.js";
|
|
2
2
|
import { dealoc } from "../../shared/dom.js";
|
|
3
3
|
import { wait } from "../../shared/test-utils.js";
|
|
4
4
|
|
|
@@ -59,4 +59,76 @@ describe("$templateCache", () => {
|
|
|
59
59
|
"<p>This is the content of the template</p>",
|
|
60
60
|
);
|
|
61
61
|
});
|
|
62
|
+
|
|
63
|
+
it("can be swapped for localStorage", async () => {
|
|
64
|
+
dealoc(el);
|
|
65
|
+
angular = new Angular();
|
|
66
|
+
angular.module("customStorage", []).config(($templateCacheProvider) => {
|
|
67
|
+
templateCacheProvider = $templateCacheProvider;
|
|
68
|
+
templateCacheProvider.cache = new LocalStorageMap();
|
|
69
|
+
templateCacheProvider.cache.set("test", "hello");
|
|
70
|
+
});
|
|
71
|
+
angular
|
|
72
|
+
.bootstrap(el, ["customStorage"])
|
|
73
|
+
.invoke((_$templateCache_, _$compile_, _$rootScope_) => {
|
|
74
|
+
templateCache = _$templateCache_;
|
|
75
|
+
$compile = _$compile_;
|
|
76
|
+
$scope = _$rootScope_;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
expect(templateCache instanceof LocalStorageMap).toBeTrue();
|
|
80
|
+
el.innerHTML = `
|
|
81
|
+
<div ng-include="'test'">test</div>
|
|
82
|
+
`;
|
|
83
|
+
expect(el.innerText).toEqual("test");
|
|
84
|
+
$compile(el)($scope);
|
|
85
|
+
await wait();
|
|
86
|
+
expect(el.innerText).toEqual("hello");
|
|
87
|
+
expect(window.localStorage.getItem("test")).toEqual("hello");
|
|
88
|
+
});
|
|
62
89
|
});
|
|
90
|
+
|
|
91
|
+
class LocalStorageMap {
|
|
92
|
+
constructor(prefix = "") {
|
|
93
|
+
this.prefix = prefix;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
_key(key) {
|
|
97
|
+
return `${this.prefix}${key}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get(key) {
|
|
101
|
+
const raw = localStorage.getItem(this._key(key));
|
|
102
|
+
if (raw === null) return undefined;
|
|
103
|
+
try {
|
|
104
|
+
return JSON.parse(raw);
|
|
105
|
+
} catch {
|
|
106
|
+
return raw;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
set(key, value) {
|
|
111
|
+
localStorage.setItem(this._key(key), value);
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
has(key) {
|
|
116
|
+
return localStorage.getItem(this._key(key)) !== null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
delete(key) {
|
|
120
|
+
localStorage.removeItem(this._key(key));
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
clear() {
|
|
125
|
+
const toRemove = [];
|
|
126
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
127
|
+
const k = localStorage.key(i);
|
|
128
|
+
if (k && k.startsWith(this.prefix)) {
|
|
129
|
+
toRemove.push(k);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
toRemove.forEach((k) => localStorage.removeItem(k));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -5,6 +5,7 @@ const TEST_URL = "src/services/template-cache/template-cache.html";
|
|
|
5
5
|
test("unit tests contain no errors", async ({ page }) => {
|
|
6
6
|
await page.goto(TEST_URL);
|
|
7
7
|
await page.content();
|
|
8
|
+
await page.waitForTimeout(1000);
|
|
8
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
10
|
/0 failures/,
|
|
10
11
|
);
|
|
@@ -60,7 +60,7 @@ export function TemplateRequestProvider() {
|
|
|
60
60
|
"$sce",
|
|
61
61
|
/**
|
|
62
62
|
*
|
|
63
|
-
* @param {import('
|
|
63
|
+
* @param {import('./exception/exception-handler.js').ErrorHandler} $exceptionHandler
|
|
64
64
|
* @param {import('../services/template-cache/interface.ts').TemplateCache} $templateCache
|
|
65
65
|
* @param {import("interface.ts").HttpService} $http
|
|
66
66
|
* @param {*} $sce
|
|
@@ -75,6 +75,7 @@ export function TemplateRequestProvider() {
|
|
|
75
75
|
// resources for keys that already are included in there. This also makes
|
|
76
76
|
// AngularTS accept any script directive, no matter its name. However, we
|
|
77
77
|
// still need to unwrap trusted types.
|
|
78
|
+
|
|
78
79
|
if (!isString(tpl) || !$templateCache.has(tpl)) {
|
|
79
80
|
try {
|
|
80
81
|
tpl = $sce.getTrustedResourceUrl(tpl);
|
package/src/shared/cache.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Expando cache for adding properties to DOM nodes with JavaScript.
|
|
3
3
|
* This used to be an Object in JQLite decorator, but swapped out for a Map
|
|
4
|
-
* for performance reasons and convenience methods. A proxy is available for
|
|
5
|
-
* additional logic handling.
|
|
6
4
|
*
|
|
7
5
|
* @type {Map<number, import('../interface.ts').ExpandoStore>}
|
|
8
6
|
*/
|
package/src/shared/common.js
CHANGED
|
@@ -133,11 +133,6 @@ export function _removeFrom(array, obj) {
|
|
|
133
133
|
if (idx >= 0) array.splice(idx, 1);
|
|
134
134
|
return array;
|
|
135
135
|
}
|
|
136
|
-
/** pushes a values to an array and returns the value */
|
|
137
|
-
export const pushTo = curry((arr, val) => {
|
|
138
|
-
arr.push(val);
|
|
139
|
-
return val;
|
|
140
|
-
});
|
|
141
136
|
|
|
142
137
|
/**
|
|
143
138
|
* Applies a set of defaults to an options object. The options object is filtered
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defaults, filter, map, pick, tail } from "./common.js";
|
|
2
2
|
import { is, pattern, val } from "./hof.js";
|
|
3
3
|
import { isInjectable } from "./predicates.js";
|
|
4
|
-
import { Queue } from "
|
|
4
|
+
import { Queue } from "./queue.js";
|
|
5
5
|
|
|
6
6
|
describe("common", function () {
|
|
7
7
|
describe("filter", function () {
|
package/src/shared/dom.js
CHANGED
|
@@ -704,3 +704,13 @@ function extractElementNode(element) {
|
|
|
704
704
|
}
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Returns the base href of the document.
|
|
710
|
+
*
|
|
711
|
+
* @returns {string} The base href.
|
|
712
|
+
*/
|
|
713
|
+
export function getBaseHref() {
|
|
714
|
+
const href = document.querySelector("base")?.getAttribute("href");
|
|
715
|
+
return href ? href.replace(/^(https?:)?\/\/[^/]*/, "") : "";
|
|
716
|
+
}
|
package/src/shared/interface.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { pushTo } from "../../shared/common.js";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* A simple bounded FIFO queue with optional eviction notifications.
|
|
5
3
|
* @template T
|
|
@@ -18,12 +16,14 @@ export class Queue {
|
|
|
18
16
|
|
|
19
17
|
/** @type {Array<(item: T) => void>} */
|
|
20
18
|
this._evictListeners = [];
|
|
19
|
+
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Register a listener that will be called with the evicted item.
|
|
23
|
+
* @param {(item: T) => void} listener
|
|
24
|
+
*/
|
|
25
|
+
onEvict(listener) {
|
|
26
|
+
this._evictListeners.push(listener);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
package/src/shared/shared.html
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<script type="module" src="/src/shared/common.spec.js"></script>
|
|
15
15
|
<script type="module" src="/src/shared/hof.spec.js"></script>
|
|
16
16
|
<script type="module" src="/src/shared/min-err.spec.js"></script>
|
|
17
|
+
<script type="module" src="/src/shared/queue.spec.js"></script>
|
|
17
18
|
<script type="module" src="/src/shared/strings.spec.js"></script>
|
|
18
19
|
<script type="module" src="/src/shared/utils.spec.js"></script>
|
|
19
20
|
</head>
|
|
@@ -5,6 +5,7 @@ const TEST_URL = "src/shared/shared.html";
|
|
|
5
5
|
test("unit tests contain no errors", async ({ page }) => {
|
|
6
6
|
await page.goto(TEST_URL);
|
|
7
7
|
await page.content();
|
|
8
|
+
await page.waitForTimeout(1000);
|
|
8
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
10
|
/0 failures/,
|
|
10
11
|
);
|
package/src/shared/test-utils.js
CHANGED
|
@@ -22,6 +22,7 @@ export function browserTrigger(element, options) {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Delays execution for a specified number of milliseconds.
|
|
25
|
+
* TODO remove
|
|
25
26
|
*
|
|
26
27
|
* @param {number} [t=0] - The number of milliseconds to wait. Defaults to 0.
|
|
27
28
|
* @returns {Promise<void>} A promise that resolves after the delay.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A normalized representation of a parsed URL.
|
|
3
|
+
*/
|
|
4
|
+
export interface ParsedUrl {
|
|
5
|
+
/**
|
|
6
|
+
* The full URL string, including protocol, host, path, query, and hash.
|
|
7
|
+
* Example: "https://example.com:8080/path?query=1#section"
|
|
8
|
+
*/
|
|
9
|
+
href: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The protocol scheme of the URL, without the trailing colon.
|
|
13
|
+
* Example: "http" or "https"
|
|
14
|
+
*/
|
|
15
|
+
protocol: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The host part of the URL, including hostname and port (if specified).
|
|
19
|
+
* Example: "example.com:8080"
|
|
20
|
+
*/
|
|
21
|
+
host: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The query string portion of the URL, without the leading "?".
|
|
25
|
+
* Example: "query=1&sort=asc"
|
|
26
|
+
*/
|
|
27
|
+
search: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The fragment identifier (hash) of the URL, without the leading "#".
|
|
31
|
+
* Example: "section2"
|
|
32
|
+
*/
|
|
33
|
+
hash: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The domain or IP address (including IPv6 in brackets) of the URL.
|
|
37
|
+
* Example: "example.com" or "[::1]"
|
|
38
|
+
*/
|
|
39
|
+
hostname: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The port number of the URL as a string, or an empty string if not specified.
|
|
43
|
+
* Example: "8080" or ""
|
|
44
|
+
*/
|
|
45
|
+
port: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The path of the URL, always beginning with a leading slash.
|
|
49
|
+
* Example: "/path/to/resource"
|
|
50
|
+
*/
|
|
51
|
+
pathname: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type ResolvableUrl = string | ParsedUrl;
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
<script src="/jasmine/jasmine-html.js"></script>
|
|
12
12
|
<script src="/jasmine/boot0.js"></script>
|
|
13
13
|
<script src="/jasmine/boot1.js"></script>
|
|
14
|
-
<script
|
|
14
|
+
<script
|
|
15
|
+
type="module"
|
|
16
|
+
src="/src/shared/url-utils/url-utils.spec.js"
|
|
17
|
+
></script>
|
|
15
18
|
</head>
|
|
16
19
|
<body>
|
|
17
20
|
<div id="app"></div>
|
|
@@ -1,37 +1,27 @@
|
|
|
1
1
|
import { isString } from "../../shared/utils.js";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* HTTP protocol
|
|
5
|
-
* @typedef {"http"|"https"} HttpProtocol
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const urlParsingNode = document.createElement("a");
|
|
9
3
|
const originUrl = urlResolve(window.location.href);
|
|
10
|
-
let baseUrlParsingNode;
|
|
11
|
-
|
|
12
|
-
urlParsingNode.href = "http://[::1]";
|
|
13
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @param {import("./interface.js").ResolvableUrl} url
|
|
7
|
+
* @return {import("./interface.js").ParsedUrl}
|
|
8
|
+
*/
|
|
14
9
|
export function urlResolve(url) {
|
|
15
|
-
if (!isString(url))
|
|
10
|
+
if (!isString(url))
|
|
11
|
+
return /** @type {import("./interface.js").ParsedUrl} */ (url);
|
|
16
12
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const urlParsingNode = new URL(
|
|
14
|
+
/** @type {string} */ (url),
|
|
15
|
+
window.location.href,
|
|
16
|
+
);
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// when parsed out of an anchor element.
|
|
25
|
-
const ipv6InBrackets = urlParsingNode.hostname === "[::1]";
|
|
26
|
-
if (!ipv6InBrackets && hostname.indexOf(":") > -1) {
|
|
27
|
-
hostname = `[${hostname}]`;
|
|
28
|
-
}
|
|
18
|
+
const hostname = urlParsingNode.hostname.includes(":")
|
|
19
|
+
? `[${urlParsingNode.hostname}]`
|
|
20
|
+
: urlParsingNode.hostname;
|
|
29
21
|
|
|
30
22
|
return {
|
|
31
23
|
href: urlParsingNode.href,
|
|
32
|
-
protocol: urlParsingNode.protocol
|
|
33
|
-
? urlParsingNode.protocol.replace(/:$/, "")
|
|
34
|
-
: "",
|
|
24
|
+
protocol: urlParsingNode.protocol,
|
|
35
25
|
host: urlParsingNode.host,
|
|
36
26
|
search: urlParsingNode.search
|
|
37
27
|
? urlParsingNode.search.replace(/^\?/, "")
|
|
@@ -50,7 +40,7 @@ export function urlResolve(url) {
|
|
|
50
40
|
* Parse a request URL and determine whether this is a same-origin request as the application
|
|
51
41
|
* document.
|
|
52
42
|
*
|
|
53
|
-
* @param {
|
|
43
|
+
* @param {import("./interface.js").ResolvableUrl} requestUrl The url of the request as a string that will be resolved
|
|
54
44
|
* or a parsed URL object.
|
|
55
45
|
* @returns {boolean} Whether the request is for the same origin as the application document.
|
|
56
46
|
*/
|
|
@@ -64,12 +54,12 @@ export function urlIsSameOrigin(requestUrl) {
|
|
|
64
54
|
* Note: The base URL is usually the same as the document location (`location.href`) but can
|
|
65
55
|
* be overriden by using the `<base>` tag.
|
|
66
56
|
*
|
|
67
|
-
* @param {
|
|
57
|
+
* @param {import("./interface.js").ResolvableUrl} requestUrl The url of the request as a string that will be resolved
|
|
68
58
|
* or a parsed URL object.
|
|
69
59
|
* @returns {boolean} Whether the URL is same-origin as the document base URL.
|
|
70
60
|
*/
|
|
71
61
|
export function urlIsSameOriginAsBaseUrl(requestUrl) {
|
|
72
|
-
return urlsAreSameOrigin(requestUrl,
|
|
62
|
+
return urlsAreSameOrigin(requestUrl, document.baseURI);
|
|
73
63
|
}
|
|
74
64
|
|
|
75
65
|
/**
|
|
@@ -78,7 +68,7 @@ export function urlIsSameOriginAsBaseUrl(requestUrl) {
|
|
|
78
68
|
*
|
|
79
69
|
* @param {string[]} trustedOriginUrls - A list of URLs (strings), whose origins are trusted.
|
|
80
70
|
*
|
|
81
|
-
* @returns {
|
|
71
|
+
* @returns {(url: import("./interface.js").ResolvableUrl) => boolean } - A function that receives a URL (string or parsed URL object) and returns
|
|
82
72
|
* whether it is of an allowed origin.
|
|
83
73
|
*/
|
|
84
74
|
export function urlIsAllowedOriginFactory(trustedOriginUrls) {
|
|
@@ -91,7 +81,7 @@ export function urlIsAllowedOriginFactory(trustedOriginUrls) {
|
|
|
91
81
|
* based on a list of trusted-origin URLs. The current location's origin is implicitly
|
|
92
82
|
* trusted.
|
|
93
83
|
*
|
|
94
|
-
* @param {
|
|
84
|
+
* @param {import("./interface.js").ResolvableUrl} requestUrl - The URL to be checked (provided as a string that will be
|
|
95
85
|
* resolved or a parsed URL object).
|
|
96
86
|
*
|
|
97
87
|
* @returns {boolean} - Whether the specified URL is of an allowed origin.
|
|
@@ -107,9 +97,9 @@ export function urlIsAllowedOriginFactory(trustedOriginUrls) {
|
|
|
107
97
|
/**
|
|
108
98
|
* Determine if two URLs share the same origin.
|
|
109
99
|
*
|
|
110
|
-
* @param {
|
|
100
|
+
* @param {import("./interface.js").ResolvableUrl} url1 - First URL to compare as a string or a normalized URL in the form of
|
|
111
101
|
* a dictionary object returned by `urlResolve()`.
|
|
112
|
-
* @param {
|
|
102
|
+
* @param {import("./interface.js").ResolvableUrl} url2 - Second URL to compare as a string or a normalized URL in the form
|
|
113
103
|
* of a dictionary object returned by `urlResolve()`.
|
|
114
104
|
*
|
|
115
105
|
* @returns {boolean} - True if both URLs have the same origin, and false otherwise.
|
|
@@ -122,22 +112,11 @@ export function urlsAreSameOrigin(url1, url2) {
|
|
|
122
112
|
}
|
|
123
113
|
|
|
124
114
|
/**
|
|
125
|
-
*
|
|
115
|
+
* Removes a trailing hash ('#') from the given URL if it exists.
|
|
116
|
+
*
|
|
117
|
+
* @param {string} url
|
|
126
118
|
* @returns {string}
|
|
127
119
|
*/
|
|
128
|
-
export function
|
|
129
|
-
|
|
130
|
-
return document.baseURI;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// `document.baseURI` is available everywhere except IE
|
|
134
|
-
if (!baseUrlParsingNode) {
|
|
135
|
-
baseUrlParsingNode = document.createElement("a");
|
|
136
|
-
baseUrlParsingNode.href = ".";
|
|
137
|
-
|
|
138
|
-
// Work-around for IE bug described in Implementation Notes. The fix in `urlResolve()` is not
|
|
139
|
-
// suitable here because we need to track changes to the base URL.
|
|
140
|
-
baseUrlParsingNode = baseUrlParsingNode.cloneNode(false);
|
|
141
|
-
}
|
|
142
|
-
return baseUrlParsingNode.href;
|
|
120
|
+
export function trimEmptyHash(url) {
|
|
121
|
+
return url.replace(/#$/, "");
|
|
143
122
|
}
|