selenium-webdriver 2.47.0 → 2.52.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/CHANGES.md +96 -0
- package/NOTICE +1 -1
- package/README.md +57 -6
- package/builder.js +375 -358
- package/chrome.js +549 -586
- package/edge.js +378 -0
- package/error.js +597 -5
- package/example/google_search_generator.js +2 -4
- package/example/logging.js +6 -2
- package/executors.js +11 -27
- package/firefox/binary.js +80 -114
- package/firefox/extension.js +10 -19
- package/firefox/index.js +175 -171
- package/firefox/profile.js +221 -239
- package/http/index.js +396 -77
- package/http/util.js +35 -35
- package/ie.js +288 -309
- package/index.js +34 -125
- package/io/exec.js +58 -39
- package/io/index.js +54 -48
- package/lib/actions.js +594 -0
- package/lib/by.js +276 -0
- package/lib/capabilities.js +404 -0
- package/lib/{webdriver/command.js → command.js} +89 -72
- package/lib/{webdriver/button.js → devmode.js} +13 -8
- package/lib/events.js +210 -0
- package/lib/firefox/amd64/libnoblur64.so +0 -0
- package/lib/firefox/i386/libnoblur.so +0 -0
- package/lib/firefox/webdriver.json +6 -1
- package/lib/firefox/webdriver.xpi +0 -0
- package/lib/{webdriver/key.js → input.js} +82 -2
- package/lib/logging.js +668 -0
- package/lib/promise.js +3093 -0
- package/lib/safari/client.js +697 -659
- package/lib/session.js +79 -0
- package/{test/promise_aplus_test.js → lib/symbols.js} +15 -25
- package/lib/test/build.js +4 -4
- package/lib/test/data/click_tests/disappearing_element.html +62 -0
- package/lib/test/data/click_tests/html5_submit_buttons.html +2 -1
- package/lib/test/data/click_tests/overlapping_elements.html +70 -0
- package/lib/test/data/click_tests/partially_overlapping_elements.html +124 -0
- package/lib/test/data/click_tests/wrapped_overlapping_elements.html +13 -0
- package/lib/test/data/readOnlyPage.html +3 -1
- package/lib/test/data/selectPage.html +18 -2
- package/lib/test/data/simpleTest.html +1 -0
- package/lib/test/fileserver.js +3 -4
- package/lib/test/index.js +13 -4
- package/lib/test/resources.js +1 -1
- package/lib/until.js +428 -0
- package/lib/webdriver.js +2351 -0
- package/net/portprober.js +15 -11
- package/opera.js +295 -314
- package/package.json +6 -5
- package/phantomjs.js +135 -140
- package/proxy.js +6 -4
- package/remote/index.js +234 -219
- package/safari.js +319 -310
- package/test/chrome/options_test.js +11 -9
- package/test/element_finding_test.js +51 -13
- package/test/error_test.js +163 -0
- package/test/execute_script_test.js +1 -1
- package/test/firefox/firefox_test.js +24 -0
- package/test/http/http_test.js +354 -43
- package/test/http/util_test.js +25 -23
- package/test/io_test.js +6 -1
- package/test/lib/by_test.js +127 -0
- package/test/lib/capabilities_test.js +84 -0
- package/test/lib/events_test.js +177 -0
- package/test/lib/logging_test.js +272 -0
- package/test/lib/promise_aplus_test.js +74 -0
- package/test/lib/promise_error_test.js +808 -0
- package/test/lib/promise_flow_test.js +2282 -0
- package/test/lib/promise_generator_test.js +308 -0
- package/test/lib/promise_test.js +996 -0
- package/test/lib/testutil.js +90 -0
- package/test/lib/until_test.js +436 -0
- package/test/lib/webdriver_test.js +2207 -0
- package/test/page_loading_test.js +7 -9
- package/test/stale_element_test.js +2 -2
- package/test/testing/assert_test.js +374 -0
- package/test/testing/index_test.js +9 -11
- package/testing/assert.js +334 -17
- package/testing/index.js +10 -0
- package/_base.js +0 -200
- package/docs/Changes.html +0 -317
- package/docs/class_bot_Error.html +0 -15
- package/docs/class_webdriver_ActionSequence.html +0 -115
- package/docs/class_webdriver_Alert.html +0 -24
- package/docs/class_webdriver_AlertPromise.html +0 -91
- package/docs/class_webdriver_Capabilities.html +0 -60
- package/docs/class_webdriver_Command.html +0 -15
- package/docs/class_webdriver_EventEmitter.html +0 -35
- package/docs/class_webdriver_FileDetector.html +0 -21
- package/docs/class_webdriver_Locator.html +0 -12
- package/docs/class_webdriver_Serializable.html +0 -9
- package/docs/class_webdriver_Session.html +0 -13
- package/docs/class_webdriver_TouchSequence.html +0 -49
- package/docs/class_webdriver_UnhandledAlertError.html +0 -18
- package/docs/class_webdriver_WebDriver.html +0 -313
- package/docs/class_webdriver_WebDriver_Logs.html +0 -15
- package/docs/class_webdriver_WebDriver_Navigation.html +0 -16
- package/docs/class_webdriver_WebDriver_Options.html +0 -41
- package/docs/class_webdriver_WebDriver_TargetLocator.html +0 -38
- package/docs/class_webdriver_WebDriver_Timeouts.html +0 -29
- package/docs/class_webdriver_WebDriver_Window.html +0 -27
- package/docs/class_webdriver_WebElement.html +0 -216
- package/docs/class_webdriver_WebElementPromise.html +0 -266
- package/docs/class_webdriver_http_Executor.html +0 -22
- package/docs/class_webdriver_http_Request.html +0 -12
- package/docs/class_webdriver_http_Response.html +0 -13
- package/docs/class_webdriver_logging_Entry.html +0 -15
- package/docs/class_webdriver_logging_Level.html +0 -55
- package/docs/class_webdriver_logging_LogRecord.html +0 -45
- package/docs/class_webdriver_logging_Logger.html +0 -119
- package/docs/class_webdriver_logging_Preferences.html +0 -8
- package/docs/class_webdriver_promise_CancellationError.html +0 -18
- package/docs/class_webdriver_promise_ControlFlow.html +0 -109
- package/docs/class_webdriver_promise_Deferred.html +0 -84
- package/docs/class_webdriver_promise_Promise.html +0 -74
- package/docs/class_webdriver_stacktrace_Frame.html +0 -20
- package/docs/class_webdriver_stacktrace_Snapshot.html +0 -6
- package/docs/class_webdriver_testing_Assertion.html +0 -99
- package/docs/class_webdriver_testing_Assertion_DelegatingMatcher_.html +0 -13
- package/docs/class_webdriver_testing_ContainsMatcher.html +0 -11
- package/docs/class_webdriver_testing_NegatedAssertion.html +0 -97
- package/docs/class_webdriver_until_Condition.html +0 -7
- package/docs/dossier.css +0 -1
- package/docs/dossier.js +0 -86
- package/docs/enum_bot_ErrorCode.html +0 -3
- package/docs/enum_bot_Error_State.html +0 -2
- package/docs/enum_webdriver_Browser.html +0 -2
- package/docs/enum_webdriver_Button.html +0 -2
- package/docs/enum_webdriver_Capability.html +0 -33
- package/docs/enum_webdriver_CommandName.html +0 -3
- package/docs/enum_webdriver_Key.html +0 -12
- package/docs/enum_webdriver_logging_Type.html +0 -6
- package/docs/enum_webdriver_promise_ControlFlow_EventType.html +0 -9
- package/docs/index.html +0 -123
- package/docs/interface_webdriver_CommandExecutor.html +0 -9
- package/docs/interface_webdriver_http_Client.html +0 -10
- package/docs/interface_webdriver_promise_Thenable.html +0 -77
- package/docs/module_selenium-webdriver.html +0 -23
- package/docs/module_selenium-webdriver__base.html +0 -23
- package/docs/module_selenium-webdriver__base_class_Context.html +0 -5
- package/docs/module_selenium-webdriver_builder.html +0 -2
- package/docs/module_selenium-webdriver_builder_class_Builder.html +0 -138
- package/docs/module_selenium-webdriver_chrome.html +0 -90
- package/docs/module_selenium-webdriver_chrome_class_Driver.html +0 -280
- package/docs/module_selenium-webdriver_chrome_class_Options.html +0 -127
- package/docs/module_selenium-webdriver_chrome_class_ServiceBuilder.html +0 -46
- package/docs/module_selenium-webdriver_class_ActionSequence.html +0 -115
- package/docs/module_selenium-webdriver_class_Builder.html +0 -138
- package/docs/module_selenium-webdriver_class_Capabilities.html +0 -60
- package/docs/module_selenium-webdriver_class_Command.html +0 -15
- package/docs/module_selenium-webdriver_class_EventEmitter.html +0 -35
- package/docs/module_selenium-webdriver_class_FileDetector.html +0 -21
- package/docs/module_selenium-webdriver_class_Serializable.html +0 -9
- package/docs/module_selenium-webdriver_class_Session.html +0 -13
- package/docs/module_selenium-webdriver_class_WebDriver.html +0 -313
- package/docs/module_selenium-webdriver_class_WebElement.html +0 -216
- package/docs/module_selenium-webdriver_class_WebElementPromise.html +0 -266
- package/docs/module_selenium-webdriver_enum_Browser.html +0 -2
- package/docs/module_selenium-webdriver_enum_Button.html +0 -2
- package/docs/module_selenium-webdriver_enum_Capability.html +0 -33
- package/docs/module_selenium-webdriver_enum_CommandName.html +0 -3
- package/docs/module_selenium-webdriver_enum_Key.html +0 -12
- package/docs/module_selenium-webdriver_error.html +0 -4
- package/docs/module_selenium-webdriver_error_class_Error.html +0 -15
- package/docs/module_selenium-webdriver_error_enum_ErrorCode.html +0 -3
- package/docs/module_selenium-webdriver_executors.html +0 -10
- package/docs/module_selenium-webdriver_executors_class_DeferredExecutor.html +0 -12
- package/docs/module_selenium-webdriver_firefox.html +0 -67
- package/docs/module_selenium-webdriver_firefox_binary.html +0 -4
- package/docs/module_selenium-webdriver_firefox_binary_class_Binary.html +0 -21
- package/docs/module_selenium-webdriver_firefox_class_Binary.html +0 -21
- package/docs/module_selenium-webdriver_firefox_class_Driver.html +0 -276
- package/docs/module_selenium-webdriver_firefox_class_Options.html +0 -19
- package/docs/module_selenium-webdriver_firefox_class_Profile.html +0 -50
- package/docs/module_selenium-webdriver_firefox_extension.html +0 -8
- package/docs/module_selenium-webdriver_firefox_profile.html +0 -13
- package/docs/module_selenium-webdriver_firefox_profile_class_Profile.html +0 -50
- package/docs/module_selenium-webdriver_http.html +0 -9
- package/docs/module_selenium-webdriver_http_class_Executor.html +0 -22
- package/docs/module_selenium-webdriver_http_class_HttpClient.html +0 -16
- package/docs/module_selenium-webdriver_http_class_Request.html +0 -12
- package/docs/module_selenium-webdriver_http_class_Response.html +0 -13
- package/docs/module_selenium-webdriver_http_util.html +0 -17
- package/docs/module_selenium-webdriver_ie.html +0 -11
- package/docs/module_selenium-webdriver_ie_class_Driver.html +0 -274
- package/docs/module_selenium-webdriver_ie_class_Options.html +0 -89
- package/docs/module_selenium-webdriver_ie_enum_Level.html +0 -1
- package/docs/module_selenium-webdriver_io.html +0 -37
- package/docs/module_selenium-webdriver_io_exec.html +0 -6
- package/docs/module_selenium-webdriver_namespace_By.html +0 -56
- package/docs/module_selenium-webdriver_namespace_error.html +0 -4
- package/docs/module_selenium-webdriver_namespace_logging.html +0 -18
- package/docs/module_selenium-webdriver_namespace_promise.html +0 -162
- package/docs/module_selenium-webdriver_namespace_stacktrace.html +0 -17
- package/docs/module_selenium-webdriver_namespace_until.html +0 -82
- package/docs/module_selenium-webdriver_net.html +0 -7
- package/docs/module_selenium-webdriver_net_portprober.html +0 -12
- package/docs/module_selenium-webdriver_opera.html +0 -62
- package/docs/module_selenium-webdriver_opera_class_Driver.html +0 -276
- package/docs/module_selenium-webdriver_opera_class_Options.html +0 -44
- package/docs/module_selenium-webdriver_opera_class_ServiceBuilder.html +0 -35
- package/docs/module_selenium-webdriver_phantomjs.html +0 -2
- package/docs/module_selenium-webdriver_phantomjs_class_Driver.html +0 -299
- package/docs/module_selenium-webdriver_proxy.html +0 -28
- package/docs/module_selenium-webdriver_remote.html +0 -8
- package/docs/module_selenium-webdriver_remote_class_DriverService.html +0 -32
- package/docs/module_selenium-webdriver_remote_class_FileDetector.html +0 -22
- package/docs/module_selenium-webdriver_remote_class_SeleniumServer.html +0 -40
- package/docs/module_selenium-webdriver_safari.html +0 -9
- package/docs/module_selenium-webdriver_safari_class_Driver.html +0 -279
- package/docs/module_selenium-webdriver_safari_class_Options.html +0 -23
- package/docs/module_selenium-webdriver_testing.html +0 -74
- package/docs/module_selenium-webdriver_testing_assert.html +0 -9
- package/docs/namespace_bot.html +0 -4
- package/docs/namespace_bot_json.html +0 -20
- package/docs/namespace_bot_response.html +0 -18
- package/docs/namespace_bot_userAgent.html +0 -33
- package/docs/namespace_webdriver.html +0 -30
- package/docs/namespace_webdriver_By.html +0 -56
- package/docs/namespace_webdriver_http.html +0 -6
- package/docs/namespace_webdriver_logging.html +0 -70
- package/docs/namespace_webdriver_promise.html +0 -165
- package/docs/namespace_webdriver_stacktrace.html +0 -17
- package/docs/namespace_webdriver_testing.html +0 -7
- package/docs/namespace_webdriver_testing_assert.html +0 -9
- package/docs/namespace_webdriver_testing_asserts.html +0 -18
- package/docs/namespace_webdriver_until.html +0 -82
- package/docs/source/_base.js.src.html +0 -1
- package/docs/source/builder.js.src.html +0 -1
- package/docs/source/chrome.js.src.html +0 -1
- package/docs/source/error.js.src.html +0 -1
- package/docs/source/executors.js.src.html +0 -1
- package/docs/source/firefox/binary.js.src.html +0 -1
- package/docs/source/firefox/extension.js.src.html +0 -1
- package/docs/source/firefox/index.js.src.html +0 -1
- package/docs/source/firefox/profile.js.src.html +0 -1
- package/docs/source/http/index.js.src.html +0 -1
- package/docs/source/http/util.js.src.html +0 -1
- package/docs/source/ie.js.src.html +0 -1
- package/docs/source/index.js.src.html +0 -1
- package/docs/source/io/exec.js.src.html +0 -1
- package/docs/source/io/index.js.src.html +0 -1
- package/docs/source/lib/atoms/error.js.src.html +0 -1
- package/docs/source/lib/atoms/json.js.src.html +0 -1
- package/docs/source/lib/atoms/response.js.src.html +0 -1
- package/docs/source/lib/atoms/userAgent.js.src.html +0 -1
- package/docs/source/lib/goog/array/array.js.src.html +0 -1
- package/docs/source/lib/goog/asserts/asserts.js.src.html +0 -1
- package/docs/source/lib/goog/async/freelist.js.src.html +0 -1
- package/docs/source/lib/goog/async/nexttick.js.src.html +0 -1
- package/docs/source/lib/goog/async/run.js.src.html +0 -1
- package/docs/source/lib/goog/async/workqueue.js.src.html +0 -1
- package/docs/source/lib/goog/base.js.src.html +0 -1
- package/docs/source/lib/goog/debug/debug.js.src.html +0 -1
- package/docs/source/lib/goog/debug/entrypointregistry.js.src.html +0 -1
- package/docs/source/lib/goog/debug/error.js.src.html +0 -1
- package/docs/source/lib/goog/debug/logbuffer.js.src.html +0 -1
- package/docs/source/lib/goog/debug/logger.js.src.html +0 -1
- package/docs/source/lib/goog/debug/logrecord.js.src.html +0 -1
- package/docs/source/lib/goog/deps.js.src.html +0 -1
- package/docs/source/lib/goog/disposable/disposable.js.src.html +0 -1
- package/docs/source/lib/goog/disposable/idisposable.js.src.html +0 -1
- package/docs/source/lib/goog/dom/browserfeature.js.src.html +0 -1
- package/docs/source/lib/goog/dom/dom.js.src.html +0 -1
- package/docs/source/lib/goog/dom/nodetype.js.src.html +0 -1
- package/docs/source/lib/goog/dom/safe.js.src.html +0 -1
- package/docs/source/lib/goog/dom/tagname.js.src.html +0 -1
- package/docs/source/lib/goog/dom/tags.js.src.html +0 -1
- package/docs/source/lib/goog/dom/vendor.js.src.html +0 -1
- package/docs/source/lib/goog/events/browserevent.js.src.html +0 -1
- package/docs/source/lib/goog/events/browserfeature.js.src.html +0 -1
- package/docs/source/lib/goog/events/event.js.src.html +0 -1
- package/docs/source/lib/goog/events/eventid.js.src.html +0 -1
- package/docs/source/lib/goog/events/events.js.src.html +0 -1
- package/docs/source/lib/goog/events/eventtarget.js.src.html +0 -1
- package/docs/source/lib/goog/events/eventtype.js.src.html +0 -1
- package/docs/source/lib/goog/events/keycodes.js.src.html +0 -1
- package/docs/source/lib/goog/events/listenable.js.src.html +0 -1
- package/docs/source/lib/goog/events/listener.js.src.html +0 -1
- package/docs/source/lib/goog/events/listenermap.js.src.html +0 -1
- package/docs/source/lib/goog/fs/url.js.src.html +0 -1
- package/docs/source/lib/goog/functions/functions.js.src.html +0 -1
- package/docs/source/lib/goog/html/safehtml.js.src.html +0 -1
- package/docs/source/lib/goog/html/safescript.js.src.html +0 -1
- package/docs/source/lib/goog/html/safestyle.js.src.html +0 -1
- package/docs/source/lib/goog/html/safestylesheet.js.src.html +0 -1
- package/docs/source/lib/goog/html/safeurl.js.src.html +0 -1
- package/docs/source/lib/goog/html/trustedresourceurl.js.src.html +0 -1
- package/docs/source/lib/goog/html/uncheckedconversions.js.src.html +0 -1
- package/docs/source/lib/goog/i18n/bidi.js.src.html +0 -1
- package/docs/source/lib/goog/iter/iter.js.src.html +0 -1
- package/docs/source/lib/goog/json/json.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/assertthat.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/logicmatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/matcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/numbermatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/objectmatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/stringmatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/browser.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/engine.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/platform.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/util.js.src.html +0 -1
- package/docs/source/lib/goog/math/box.js.src.html +0 -1
- package/docs/source/lib/goog/math/coordinate.js.src.html +0 -1
- package/docs/source/lib/goog/math/math.js.src.html +0 -1
- package/docs/source/lib/goog/math/rect.js.src.html +0 -1
- package/docs/source/lib/goog/math/size.js.src.html +0 -1
- package/docs/source/lib/goog/net/wrapperxmlhttpfactory.js.src.html +0 -1
- package/docs/source/lib/goog/net/xhrlike.js.src.html +0 -1
- package/docs/source/lib/goog/net/xmlhttp.js.src.html +0 -1
- package/docs/source/lib/goog/net/xmlhttpfactory.js.src.html +0 -1
- package/docs/source/lib/goog/object/object.js.src.html +0 -1
- package/docs/source/lib/goog/promise/promise.js.src.html +0 -1
- package/docs/source/lib/goog/promise/resolver.js.src.html +0 -1
- package/docs/source/lib/goog/promise/thenable.js.src.html +0 -1
- package/docs/source/lib/goog/reflect/reflect.js.src.html +0 -1
- package/docs/source/lib/goog/string/const.js.src.html +0 -1
- package/docs/source/lib/goog/string/string.js.src.html +0 -1
- package/docs/source/lib/goog/string/typedstring.js.src.html +0 -1
- package/docs/source/lib/goog/structs/collection.js.src.html +0 -1
- package/docs/source/lib/goog/structs/map.js.src.html +0 -1
- package/docs/source/lib/goog/structs/set.js.src.html +0 -1
- package/docs/source/lib/goog/structs/structs.js.src.html +0 -1
- package/docs/source/lib/goog/style/style.js.src.html +0 -1
- package/docs/source/lib/goog/testing/asserts.js.src.html +0 -1
- package/docs/source/lib/goog/testing/events/events.js.src.html +0 -1
- package/docs/source/lib/goog/testing/functionmock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/jsunit.js.src.html +0 -1
- package/docs/source/lib/goog/testing/loosemock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockclock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockcontrol.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockinterface.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockmatchers.js.src.html +0 -1
- package/docs/source/lib/goog/testing/objectpropertystring.js.src.html +0 -1
- package/docs/source/lib/goog/testing/propertyreplacer.js.src.html +0 -1
- package/docs/source/lib/goog/testing/recordfunction.js.src.html +0 -1
- package/docs/source/lib/goog/testing/stacktrace.js.src.html +0 -1
- package/docs/source/lib/goog/testing/strictmock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/testcase.js.src.html +0 -1
- package/docs/source/lib/goog/testing/testrunner.js.src.html +0 -1
- package/docs/source/lib/goog/testing/watchers.js.src.html +0 -1
- package/docs/source/lib/goog/uri/uri.js.src.html +0 -1
- package/docs/source/lib/goog/uri/utils.js.src.html +0 -1
- package/docs/source/lib/goog/useragent/product.js.src.html +0 -1
- package/docs/source/lib/goog/useragent/product_isversion.js.src.html +0 -1
- package/docs/source/lib/goog/useragent/useragent.js.src.html +0 -1
- package/docs/source/lib/webdriver/actionsequence.js.src.html +0 -1
- package/docs/source/lib/webdriver/button.js.src.html +0 -1
- package/docs/source/lib/webdriver/capabilities.js.src.html +0 -1
- package/docs/source/lib/webdriver/command.js.src.html +0 -1
- package/docs/source/lib/webdriver/events.js.src.html +0 -1
- package/docs/source/lib/webdriver/http/http.js.src.html +0 -1
- package/docs/source/lib/webdriver/key.js.src.html +0 -1
- package/docs/source/lib/webdriver/locators.js.src.html +0 -1
- package/docs/source/lib/webdriver/logging.js.src.html +0 -1
- package/docs/source/lib/webdriver/promise.js.src.html +0 -1
- package/docs/source/lib/webdriver/serializable.js.src.html +0 -1
- package/docs/source/lib/webdriver/session.js.src.html +0 -1
- package/docs/source/lib/webdriver/stacktrace.js.src.html +0 -1
- package/docs/source/lib/webdriver/testing/asserts.js.src.html +0 -1
- package/docs/source/lib/webdriver/touchsequence.js.src.html +0 -1
- package/docs/source/lib/webdriver/until.js.src.html +0 -1
- package/docs/source/lib/webdriver/webdriver.js.src.html +0 -1
- package/docs/source/net/index.js.src.html +0 -1
- package/docs/source/net/portprober.js.src.html +0 -1
- package/docs/source/opera.js.src.html +0 -1
- package/docs/source/phantomjs.js.src.html +0 -1
- package/docs/source/proxy.js.src.html +0 -1
- package/docs/source/remote/index.js.src.html +0 -1
- package/docs/source/safari.js.src.html +0 -1
- package/docs/source/testing/assert.js.src.html +0 -1
- package/docs/source/testing/index.js.src.html +0 -1
- package/docs/types.js +0 -1
- package/lib/atoms/error.js +0 -202
- package/lib/atoms/json.js +0 -80
- package/lib/atoms/response.js +0 -110
- package/lib/atoms/userAgent.js +0 -257
- package/lib/goog/LICENSE +0 -176
- package/lib/goog/array/array.js +0 -1655
- package/lib/goog/asserts/asserts.js +0 -365
- package/lib/goog/async/freelist.js +0 -88
- package/lib/goog/async/nexttick.js +0 -241
- package/lib/goog/async/run.js +0 -139
- package/lib/goog/async/workqueue.js +0 -139
- package/lib/goog/base.js +0 -2547
- package/lib/goog/debug/debug.js +0 -653
- package/lib/goog/debug/entrypointregistry.js +0 -158
- package/lib/goog/debug/error.js +0 -63
- package/lib/goog/debug/logbuffer.js +0 -148
- package/lib/goog/debug/logger.js +0 -873
- package/lib/goog/debug/logrecord.js +0 -242
- package/lib/goog/deps.js +0 -151
- package/lib/goog/disposable/disposable.js +0 -307
- package/lib/goog/disposable/idisposable.js +0 -45
- package/lib/goog/dom/browserfeature.js +0 -72
- package/lib/goog/dom/dom.js +0 -2995
- package/lib/goog/dom/nodetype.js +0 -48
- package/lib/goog/dom/safe.js +0 -347
- package/lib/goog/dom/tagname.js +0 -160
- package/lib/goog/dom/tags.js +0 -42
- package/lib/goog/dom/vendor.js +0 -96
- package/lib/goog/events/browserevent.js +0 -386
- package/lib/goog/events/browserfeature.js +0 -85
- package/lib/goog/events/event.js +0 -143
- package/lib/goog/events/eventid.js +0 -47
- package/lib/goog/events/events.js +0 -984
- package/lib/goog/events/eventtarget.js +0 -394
- package/lib/goog/events/eventtype.js +0 -233
- package/lib/goog/events/keycodes.js +0 -420
- package/lib/goog/events/listenable.js +0 -335
- package/lib/goog/events/listener.js +0 -131
- package/lib/goog/events/listenermap.js +0 -308
- package/lib/goog/fs/url.js +0 -105
- package/lib/goog/functions/functions.js +0 -332
- package/lib/goog/html/safehtml.js +0 -756
- package/lib/goog/html/safescript.js +0 -234
- package/lib/goog/html/safestyle.js +0 -442
- package/lib/goog/html/safestylesheet.js +0 -276
- package/lib/goog/html/safeurl.js +0 -431
- package/lib/goog/html/trustedresourceurl.js +0 -224
- package/lib/goog/html/uncheckedconversions.js +0 -231
- package/lib/goog/i18n/bidi.js +0 -908
- package/lib/goog/iter/iter.js +0 -1305
- package/lib/goog/json/json.js +0 -365
- package/lib/goog/labs/testing/assertthat.js +0 -58
- package/lib/goog/labs/testing/logicmatcher.js +0 -212
- package/lib/goog/labs/testing/matcher.js +0 -80
- package/lib/goog/labs/testing/numbermatcher.js +0 -346
- package/lib/goog/labs/testing/objectmatcher.js +0 -317
- package/lib/goog/labs/testing/stringmatcher.js +0 -415
- package/lib/goog/labs/useragent/browser.js +0 -327
- package/lib/goog/labs/useragent/engine.js +0 -160
- package/lib/goog/labs/useragent/platform.js +0 -160
- package/lib/goog/labs/useragent/util.js +0 -148
- package/lib/goog/math/box.js +0 -389
- package/lib/goog/math/coordinate.js +0 -268
- package/lib/goog/math/math.js +0 -451
- package/lib/goog/math/rect.js +0 -476
- package/lib/goog/math/size.js +0 -227
- package/lib/goog/net/wrapperxmlhttpfactory.js +0 -71
- package/lib/goog/net/xhrlike.js +0 -124
- package/lib/goog/net/xmlhttp.js +0 -246
- package/lib/goog/net/xmlhttpfactory.js +0 -67
- package/lib/goog/object/object.js +0 -686
- package/lib/goog/promise/promise.js +0 -1310
- package/lib/goog/promise/resolver.js +0 -48
- package/lib/goog/promise/thenable.js +0 -126
- package/lib/goog/reflect/reflect.js +0 -78
- package/lib/goog/string/const.js +0 -182
- package/lib/goog/string/string.js +0 -1565
- package/lib/goog/string/typedstring.js +0 -48
- package/lib/goog/structs/collection.js +0 -56
- package/lib/goog/structs/map.js +0 -456
- package/lib/goog/structs/set.js +0 -279
- package/lib/goog/structs/structs.js +0 -354
- package/lib/goog/style/style.js +0 -2054
- package/lib/goog/testing/asserts.js +0 -1265
- package/lib/goog/testing/events/events.js +0 -727
- package/lib/goog/testing/functionmock.js +0 -176
- package/lib/goog/testing/jsunit.js +0 -162
- package/lib/goog/testing/loosemock.js +0 -242
- package/lib/goog/testing/mock.js +0 -645
- package/lib/goog/testing/mockclock.js +0 -617
- package/lib/goog/testing/mockcontrol.js +0 -220
- package/lib/goog/testing/mockinterface.js +0 -45
- package/lib/goog/testing/mockmatchers.js +0 -400
- package/lib/goog/testing/objectpropertystring.js +0 -68
- package/lib/goog/testing/propertyreplacer.js +0 -245
- package/lib/goog/testing/recordfunction.js +0 -215
- package/lib/goog/testing/stacktrace.js +0 -594
- package/lib/goog/testing/strictmock.js +0 -130
- package/lib/goog/testing/testcase.js +0 -1569
- package/lib/goog/testing/testrunner.js +0 -440
- package/lib/goog/testing/watchers.js +0 -46
- package/lib/goog/uri/uri.js +0 -1507
- package/lib/goog/uri/utils.js +0 -1116
- package/lib/goog/useragent/product.js +0 -175
- package/lib/goog/useragent/product_isversion.js +0 -143
- package/lib/goog/useragent/useragent.js +0 -538
- package/lib/webdriver/actionsequence.js +0 -356
- package/lib/webdriver/builder.js +0 -208
- package/lib/webdriver/capabilities.js +0 -411
- package/lib/webdriver/events.js +0 -179
- package/lib/webdriver/firefoxdomexecutor.js +0 -175
- package/lib/webdriver/http/corsclient.js +0 -133
- package/lib/webdriver/http/http.js +0 -523
- package/lib/webdriver/http/xhrclient.js +0 -67
- package/lib/webdriver/locators.js +0 -257
- package/lib/webdriver/logging.js +0 -347
- package/lib/webdriver/promise.js +0 -2609
- package/lib/webdriver/serializable.js +0 -41
- package/lib/webdriver/session.js +0 -74
- package/lib/webdriver/stacktrace.js +0 -619
- package/lib/webdriver/test/builder_test.js +0 -53
- package/lib/webdriver/test/capabilities_test.js +0 -72
- package/lib/webdriver/test/events_test.js +0 -203
- package/lib/webdriver/test/http/corsclient_test.js +0 -151
- package/lib/webdriver/test/http/http_test.js +0 -428
- package/lib/webdriver/test/http/xhrclient_test.js +0 -196
- package/lib/webdriver/test/locators_test.js +0 -59
- package/lib/webdriver/test/logging_test.js +0 -85
- package/lib/webdriver/test/promise_error_test.js +0 -719
- package/lib/webdriver/test/promise_flow_test.js +0 -1957
- package/lib/webdriver/test/promise_generator_test.js +0 -251
- package/lib/webdriver/test/promise_test.js +0 -1981
- package/lib/webdriver/test/stacktrace_test.js +0 -480
- package/lib/webdriver/test/test_bootstrap.js +0 -67
- package/lib/webdriver/test/testing/asserts_test.js +0 -117
- package/lib/webdriver/test/testing/client_test.js +0 -88
- package/lib/webdriver/test/testing/testcase_test.js +0 -229
- package/lib/webdriver/test/testutil.js +0 -209
- package/lib/webdriver/test/testutil_test.js +0 -104
- package/lib/webdriver/test/until_test.js +0 -411
- package/lib/webdriver/test/webdriver_generator_test.js +0 -92
- package/lib/webdriver/test/webdriver_test.js +0 -2369
- package/lib/webdriver/testing/asserts.js +0 -487
- package/lib/webdriver/testing/client.js +0 -179
- package/lib/webdriver/testing/jsunit.js +0 -363
- package/lib/webdriver/testing/testcase.js +0 -168
- package/lib/webdriver/testing/window.js +0 -244
- package/lib/webdriver/touchsequence.js +0 -248
- package/lib/webdriver/until.js +0 -412
- package/lib/webdriver/webdriver.js +0 -2492
- package/test/_base_test.js +0 -129
package/lib/goog/uri/uri.js
DELETED
|
@@ -1,1507 +0,0 @@
|
|
|
1
|
-
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS-IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @fileoverview Class for parsing and formatting URIs.
|
|
17
|
-
*
|
|
18
|
-
* Use goog.Uri(string) to parse a URI string. Use goog.Uri.create(...) to
|
|
19
|
-
* create a new instance of the goog.Uri object from Uri parts.
|
|
20
|
-
*
|
|
21
|
-
* e.g: <code>var myUri = new goog.Uri(window.location);</code>
|
|
22
|
-
*
|
|
23
|
-
* Implements RFC 3986 for parsing/formatting URIs.
|
|
24
|
-
* http://www.ietf.org/rfc/rfc3986.txt
|
|
25
|
-
*
|
|
26
|
-
* Some changes have been made to the interface (more like .NETs), though the
|
|
27
|
-
* internal representation is now of un-encoded parts, this will change the
|
|
28
|
-
* behavior slightly.
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
goog.provide('goog.Uri');
|
|
33
|
-
goog.provide('goog.Uri.QueryData');
|
|
34
|
-
|
|
35
|
-
goog.require('goog.array');
|
|
36
|
-
goog.require('goog.string');
|
|
37
|
-
goog.require('goog.structs');
|
|
38
|
-
goog.require('goog.structs.Map');
|
|
39
|
-
goog.require('goog.uri.utils');
|
|
40
|
-
goog.require('goog.uri.utils.ComponentIndex');
|
|
41
|
-
goog.require('goog.uri.utils.StandardQueryParam');
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* This class contains setters and getters for the parts of the URI.
|
|
47
|
-
* The <code>getXyz</code>/<code>setXyz</code> methods return the decoded part
|
|
48
|
-
* -- so<code>goog.Uri.parse('/foo%20bar').getPath()</code> will return the
|
|
49
|
-
* decoded path, <code>/foo bar</code>.
|
|
50
|
-
*
|
|
51
|
-
* Reserved characters (see RFC 3986 section 2.2) can be present in
|
|
52
|
-
* their percent-encoded form in scheme, domain, and path URI components and
|
|
53
|
-
* will not be auto-decoded. For example:
|
|
54
|
-
* <code>goog.Uri.parse('rel%61tive/path%2fto/resource').getPath()</code> will
|
|
55
|
-
* return <code>relative/path%2fto/resource</code>.
|
|
56
|
-
*
|
|
57
|
-
* The constructor accepts an optional unparsed, raw URI string. The parser
|
|
58
|
-
* is relaxed, so special characters that aren't escaped but don't cause
|
|
59
|
-
* ambiguities will not cause parse failures.
|
|
60
|
-
*
|
|
61
|
-
* All setters return <code>this</code> and so may be chained, a la
|
|
62
|
-
* <code>goog.Uri.parse('/foo').setFragment('part').toString()</code>.
|
|
63
|
-
*
|
|
64
|
-
* @param {*=} opt_uri Optional string URI to parse
|
|
65
|
-
* (use goog.Uri.create() to create a URI from parts), or if
|
|
66
|
-
* a goog.Uri is passed, a clone is created.
|
|
67
|
-
* @param {boolean=} opt_ignoreCase If true, #getParameterValue will ignore
|
|
68
|
-
* the case of the parameter name.
|
|
69
|
-
*
|
|
70
|
-
* @constructor
|
|
71
|
-
* @struct
|
|
72
|
-
*/
|
|
73
|
-
goog.Uri = function(opt_uri, opt_ignoreCase) {
|
|
74
|
-
/**
|
|
75
|
-
* Scheme such as "http".
|
|
76
|
-
* @private {string}
|
|
77
|
-
*/
|
|
78
|
-
this.scheme_ = '';
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* User credentials in the form "username:password".
|
|
82
|
-
* @private {string}
|
|
83
|
-
*/
|
|
84
|
-
this.userInfo_ = '';
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Domain part, e.g. "www.google.com".
|
|
88
|
-
* @private {string}
|
|
89
|
-
*/
|
|
90
|
-
this.domain_ = '';
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Port, e.g. 8080.
|
|
94
|
-
* @private {?number}
|
|
95
|
-
*/
|
|
96
|
-
this.port_ = null;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Path, e.g. "/tests/img.png".
|
|
100
|
-
* @private {string}
|
|
101
|
-
*/
|
|
102
|
-
this.path_ = '';
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* The fragment without the #.
|
|
106
|
-
* @private {string}
|
|
107
|
-
*/
|
|
108
|
-
this.fragment_ = '';
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Whether or not this Uri should be treated as Read Only.
|
|
112
|
-
* @private {boolean}
|
|
113
|
-
*/
|
|
114
|
-
this.isReadOnly_ = false;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Whether or not to ignore case when comparing query params.
|
|
118
|
-
* @private {boolean}
|
|
119
|
-
*/
|
|
120
|
-
this.ignoreCase_ = false;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Object representing query data.
|
|
124
|
-
* @private {!goog.Uri.QueryData}
|
|
125
|
-
*/
|
|
126
|
-
this.queryData_;
|
|
127
|
-
|
|
128
|
-
// Parse in the uri string
|
|
129
|
-
var m;
|
|
130
|
-
if (opt_uri instanceof goog.Uri) {
|
|
131
|
-
this.ignoreCase_ = goog.isDef(opt_ignoreCase) ?
|
|
132
|
-
opt_ignoreCase : opt_uri.getIgnoreCase();
|
|
133
|
-
this.setScheme(opt_uri.getScheme());
|
|
134
|
-
this.setUserInfo(opt_uri.getUserInfo());
|
|
135
|
-
this.setDomain(opt_uri.getDomain());
|
|
136
|
-
this.setPort(opt_uri.getPort());
|
|
137
|
-
this.setPath(opt_uri.getPath());
|
|
138
|
-
this.setQueryData(opt_uri.getQueryData().clone());
|
|
139
|
-
this.setFragment(opt_uri.getFragment());
|
|
140
|
-
} else if (opt_uri && (m = goog.uri.utils.split(String(opt_uri)))) {
|
|
141
|
-
this.ignoreCase_ = !!opt_ignoreCase;
|
|
142
|
-
|
|
143
|
-
// Set the parts -- decoding as we do so.
|
|
144
|
-
// COMPATABILITY NOTE - In IE, unmatched fields may be empty strings,
|
|
145
|
-
// whereas in other browsers they will be undefined.
|
|
146
|
-
this.setScheme(m[goog.uri.utils.ComponentIndex.SCHEME] || '', true);
|
|
147
|
-
this.setUserInfo(m[goog.uri.utils.ComponentIndex.USER_INFO] || '', true);
|
|
148
|
-
this.setDomain(m[goog.uri.utils.ComponentIndex.DOMAIN] || '', true);
|
|
149
|
-
this.setPort(m[goog.uri.utils.ComponentIndex.PORT]);
|
|
150
|
-
this.setPath(m[goog.uri.utils.ComponentIndex.PATH] || '', true);
|
|
151
|
-
this.setQueryData(m[goog.uri.utils.ComponentIndex.QUERY_DATA] || '', true);
|
|
152
|
-
this.setFragment(m[goog.uri.utils.ComponentIndex.FRAGMENT] || '', true);
|
|
153
|
-
|
|
154
|
-
} else {
|
|
155
|
-
this.ignoreCase_ = !!opt_ignoreCase;
|
|
156
|
-
this.queryData_ = new goog.Uri.QueryData(null, null, this.ignoreCase_);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* If true, we preserve the type of query parameters set programmatically.
|
|
163
|
-
*
|
|
164
|
-
* This means that if you set a parameter to a boolean, and then call
|
|
165
|
-
* getParameterValue, you will get a boolean back.
|
|
166
|
-
*
|
|
167
|
-
* If false, we will coerce parameters to strings, just as they would
|
|
168
|
-
* appear in real URIs.
|
|
169
|
-
*
|
|
170
|
-
* TODO(nicksantos): Remove this once people have time to fix all tests.
|
|
171
|
-
*
|
|
172
|
-
* @type {boolean}
|
|
173
|
-
*/
|
|
174
|
-
goog.Uri.preserveParameterTypesCompatibilityFlag = false;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Parameter name added to stop caching.
|
|
179
|
-
* @type {string}
|
|
180
|
-
*/
|
|
181
|
-
goog.Uri.RANDOM_PARAM = goog.uri.utils.StandardQueryParam.RANDOM;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* @return {string} The string form of the url.
|
|
186
|
-
* @override
|
|
187
|
-
*/
|
|
188
|
-
goog.Uri.prototype.toString = function() {
|
|
189
|
-
var out = [];
|
|
190
|
-
|
|
191
|
-
var scheme = this.getScheme();
|
|
192
|
-
if (scheme) {
|
|
193
|
-
out.push(goog.Uri.encodeSpecialChars_(
|
|
194
|
-
scheme, goog.Uri.reDisallowedInSchemeOrUserInfo_, true), ':');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
var domain = this.getDomain();
|
|
198
|
-
if (domain) {
|
|
199
|
-
out.push('//');
|
|
200
|
-
|
|
201
|
-
var userInfo = this.getUserInfo();
|
|
202
|
-
if (userInfo) {
|
|
203
|
-
out.push(goog.Uri.encodeSpecialChars_(
|
|
204
|
-
userInfo, goog.Uri.reDisallowedInSchemeOrUserInfo_, true), '@');
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
out.push(goog.Uri.removeDoubleEncoding_(goog.string.urlEncode(domain)));
|
|
208
|
-
|
|
209
|
-
var port = this.getPort();
|
|
210
|
-
if (port != null) {
|
|
211
|
-
out.push(':', String(port));
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
var path = this.getPath();
|
|
216
|
-
if (path) {
|
|
217
|
-
if (this.hasDomain() && path.charAt(0) != '/') {
|
|
218
|
-
out.push('/');
|
|
219
|
-
}
|
|
220
|
-
out.push(goog.Uri.encodeSpecialChars_(
|
|
221
|
-
path,
|
|
222
|
-
path.charAt(0) == '/' ?
|
|
223
|
-
goog.Uri.reDisallowedInAbsolutePath_ :
|
|
224
|
-
goog.Uri.reDisallowedInRelativePath_,
|
|
225
|
-
true));
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
var query = this.getEncodedQuery();
|
|
229
|
-
if (query) {
|
|
230
|
-
out.push('?', query);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
var fragment = this.getFragment();
|
|
234
|
-
if (fragment) {
|
|
235
|
-
out.push('#', goog.Uri.encodeSpecialChars_(
|
|
236
|
-
fragment, goog.Uri.reDisallowedInFragment_));
|
|
237
|
-
}
|
|
238
|
-
return out.join('');
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Resolves the given relative URI (a goog.Uri object), using the URI
|
|
244
|
-
* represented by this instance as the base URI.
|
|
245
|
-
*
|
|
246
|
-
* There are several kinds of relative URIs:<br>
|
|
247
|
-
* 1. foo - replaces the last part of the path, the whole query and fragment<br>
|
|
248
|
-
* 2. /foo - replaces the the path, the query and fragment<br>
|
|
249
|
-
* 3. //foo - replaces everything from the domain on. foo is a domain name<br>
|
|
250
|
-
* 4. ?foo - replace the query and fragment<br>
|
|
251
|
-
* 5. #foo - replace the fragment only
|
|
252
|
-
*
|
|
253
|
-
* Additionally, if relative URI has a non-empty path, all ".." and "."
|
|
254
|
-
* segments will be resolved, as described in RFC 3986.
|
|
255
|
-
*
|
|
256
|
-
* @param {!goog.Uri} relativeUri The relative URI to resolve.
|
|
257
|
-
* @return {!goog.Uri} The resolved URI.
|
|
258
|
-
*/
|
|
259
|
-
goog.Uri.prototype.resolve = function(relativeUri) {
|
|
260
|
-
|
|
261
|
-
var absoluteUri = this.clone();
|
|
262
|
-
|
|
263
|
-
// we satisfy these conditions by looking for the first part of relativeUri
|
|
264
|
-
// that is not blank and applying defaults to the rest
|
|
265
|
-
|
|
266
|
-
var overridden = relativeUri.hasScheme();
|
|
267
|
-
|
|
268
|
-
if (overridden) {
|
|
269
|
-
absoluteUri.setScheme(relativeUri.getScheme());
|
|
270
|
-
} else {
|
|
271
|
-
overridden = relativeUri.hasUserInfo();
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (overridden) {
|
|
275
|
-
absoluteUri.setUserInfo(relativeUri.getUserInfo());
|
|
276
|
-
} else {
|
|
277
|
-
overridden = relativeUri.hasDomain();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (overridden) {
|
|
281
|
-
absoluteUri.setDomain(relativeUri.getDomain());
|
|
282
|
-
} else {
|
|
283
|
-
overridden = relativeUri.hasPort();
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
var path = relativeUri.getPath();
|
|
287
|
-
if (overridden) {
|
|
288
|
-
absoluteUri.setPort(relativeUri.getPort());
|
|
289
|
-
} else {
|
|
290
|
-
overridden = relativeUri.hasPath();
|
|
291
|
-
if (overridden) {
|
|
292
|
-
// resolve path properly
|
|
293
|
-
if (path.charAt(0) != '/') {
|
|
294
|
-
// path is relative
|
|
295
|
-
if (this.hasDomain() && !this.hasPath()) {
|
|
296
|
-
// RFC 3986, section 5.2.3, case 1
|
|
297
|
-
path = '/' + path;
|
|
298
|
-
} else {
|
|
299
|
-
// RFC 3986, section 5.2.3, case 2
|
|
300
|
-
var lastSlashIndex = absoluteUri.getPath().lastIndexOf('/');
|
|
301
|
-
if (lastSlashIndex != -1) {
|
|
302
|
-
path = absoluteUri.getPath().substr(0, lastSlashIndex + 1) + path;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
path = goog.Uri.removeDotSegments(path);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (overridden) {
|
|
311
|
-
absoluteUri.setPath(path);
|
|
312
|
-
} else {
|
|
313
|
-
overridden = relativeUri.hasQuery();
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (overridden) {
|
|
317
|
-
absoluteUri.setQueryData(relativeUri.getDecodedQuery());
|
|
318
|
-
} else {
|
|
319
|
-
overridden = relativeUri.hasFragment();
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (overridden) {
|
|
323
|
-
absoluteUri.setFragment(relativeUri.getFragment());
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return absoluteUri;
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Clones the URI instance.
|
|
332
|
-
* @return {!goog.Uri} New instance of the URI object.
|
|
333
|
-
*/
|
|
334
|
-
goog.Uri.prototype.clone = function() {
|
|
335
|
-
return new goog.Uri(this);
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* @return {string} The encoded scheme/protocol for the URI.
|
|
341
|
-
*/
|
|
342
|
-
goog.Uri.prototype.getScheme = function() {
|
|
343
|
-
return this.scheme_;
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Sets the scheme/protocol.
|
|
349
|
-
* @param {string} newScheme New scheme value.
|
|
350
|
-
* @param {boolean=} opt_decode Optional param for whether to decode new value.
|
|
351
|
-
* @return {!goog.Uri} Reference to this URI object.
|
|
352
|
-
*/
|
|
353
|
-
goog.Uri.prototype.setScheme = function(newScheme, opt_decode) {
|
|
354
|
-
this.enforceReadOnly();
|
|
355
|
-
this.scheme_ = opt_decode ? goog.Uri.decodeOrEmpty_(newScheme, true) :
|
|
356
|
-
newScheme;
|
|
357
|
-
|
|
358
|
-
// remove an : at the end of the scheme so somebody can pass in
|
|
359
|
-
// window.location.protocol
|
|
360
|
-
if (this.scheme_) {
|
|
361
|
-
this.scheme_ = this.scheme_.replace(/:$/, '');
|
|
362
|
-
}
|
|
363
|
-
return this;
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* @return {boolean} Whether the scheme has been set.
|
|
369
|
-
*/
|
|
370
|
-
goog.Uri.prototype.hasScheme = function() {
|
|
371
|
-
return !!this.scheme_;
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* @return {string} The decoded user info.
|
|
377
|
-
*/
|
|
378
|
-
goog.Uri.prototype.getUserInfo = function() {
|
|
379
|
-
return this.userInfo_;
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Sets the userInfo.
|
|
385
|
-
* @param {string} newUserInfo New userInfo value.
|
|
386
|
-
* @param {boolean=} opt_decode Optional param for whether to decode new value.
|
|
387
|
-
* @return {!goog.Uri} Reference to this URI object.
|
|
388
|
-
*/
|
|
389
|
-
goog.Uri.prototype.setUserInfo = function(newUserInfo, opt_decode) {
|
|
390
|
-
this.enforceReadOnly();
|
|
391
|
-
this.userInfo_ = opt_decode ? goog.Uri.decodeOrEmpty_(newUserInfo) :
|
|
392
|
-
newUserInfo;
|
|
393
|
-
return this;
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* @return {boolean} Whether the user info has been set.
|
|
399
|
-
*/
|
|
400
|
-
goog.Uri.prototype.hasUserInfo = function() {
|
|
401
|
-
return !!this.userInfo_;
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* @return {string} The decoded domain.
|
|
407
|
-
*/
|
|
408
|
-
goog.Uri.prototype.getDomain = function() {
|
|
409
|
-
return this.domain_;
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Sets the domain.
|
|
415
|
-
* @param {string} newDomain New domain value.
|
|
416
|
-
* @param {boolean=} opt_decode Optional param for whether to decode new value.
|
|
417
|
-
* @return {!goog.Uri} Reference to this URI object.
|
|
418
|
-
*/
|
|
419
|
-
goog.Uri.prototype.setDomain = function(newDomain, opt_decode) {
|
|
420
|
-
this.enforceReadOnly();
|
|
421
|
-
this.domain_ = opt_decode ? goog.Uri.decodeOrEmpty_(newDomain, true) :
|
|
422
|
-
newDomain;
|
|
423
|
-
return this;
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* @return {boolean} Whether the domain has been set.
|
|
429
|
-
*/
|
|
430
|
-
goog.Uri.prototype.hasDomain = function() {
|
|
431
|
-
return !!this.domain_;
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* @return {?number} The port number.
|
|
437
|
-
*/
|
|
438
|
-
goog.Uri.prototype.getPort = function() {
|
|
439
|
-
return this.port_;
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Sets the port number.
|
|
445
|
-
* @param {*} newPort Port number. Will be explicitly casted to a number.
|
|
446
|
-
* @return {!goog.Uri} Reference to this URI object.
|
|
447
|
-
*/
|
|
448
|
-
goog.Uri.prototype.setPort = function(newPort) {
|
|
449
|
-
this.enforceReadOnly();
|
|
450
|
-
|
|
451
|
-
if (newPort) {
|
|
452
|
-
newPort = Number(newPort);
|
|
453
|
-
if (isNaN(newPort) || newPort < 0) {
|
|
454
|
-
throw Error('Bad port number ' + newPort);
|
|
455
|
-
}
|
|
456
|
-
this.port_ = newPort;
|
|
457
|
-
} else {
|
|
458
|
-
this.port_ = null;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
return this;
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* @return {boolean} Whether the port has been set.
|
|
467
|
-
*/
|
|
468
|
-
goog.Uri.prototype.hasPort = function() {
|
|
469
|
-
return this.port_ != null;
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* @return {string} The decoded path.
|
|
475
|
-
*/
|
|
476
|
-
goog.Uri.prototype.getPath = function() {
|
|
477
|
-
return this.path_;
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* Sets the path.
|
|
483
|
-
* @param {string} newPath New path value.
|
|
484
|
-
* @param {boolean=} opt_decode Optional param for whether to decode new value.
|
|
485
|
-
* @return {!goog.Uri} Reference to this URI object.
|
|
486
|
-
*/
|
|
487
|
-
goog.Uri.prototype.setPath = function(newPath, opt_decode) {
|
|
488
|
-
this.enforceReadOnly();
|
|
489
|
-
this.path_ = opt_decode ? goog.Uri.decodeOrEmpty_(newPath, true) : newPath;
|
|
490
|
-
return this;
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* @return {boolean} Whether the path has been set.
|
|
496
|
-
*/
|
|
497
|
-
goog.Uri.prototype.hasPath = function() {
|
|
498
|
-
return !!this.path_;
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* @return {boolean} Whether the query string has been set.
|
|
504
|
-
*/
|
|
505
|
-
goog.Uri.prototype.hasQuery = function() {
|
|
506
|
-
return this.queryData_.toString() !== '';
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Sets the query data.
|
|
512
|
-
* @param {goog.Uri.QueryData|string|undefined} queryData QueryData object.
|
|
513
|
-
* @param {boolean=} opt_decode Optional param for whether to decode new value.
|
|
514
|
-
* Applies only if queryData is a string.
|
|
515
|
-
* @return {!goog.Uri} Reference to this URI object.
|
|
516
|
-
*/
|
|
517
|
-
goog.Uri.prototype.setQueryData = function(queryData, opt_decode) {
|
|
518
|
-
this.enforceReadOnly();
|
|
519
|
-
|
|
520
|
-
if (queryData instanceof goog.Uri.QueryData) {
|
|
521
|
-
this.queryData_ = queryData;
|
|
522
|
-
this.queryData_.setIgnoreCase(this.ignoreCase_);
|
|
523
|
-
} else {
|
|
524
|
-
if (!opt_decode) {
|
|
525
|
-
// QueryData accepts encoded query string, so encode it if
|
|
526
|
-
// opt_decode flag is not true.
|
|
527
|
-
queryData = goog.Uri.encodeSpecialChars_(queryData,
|
|
528
|
-
goog.Uri.reDisallowedInQuery_);
|
|
529
|
-
}
|
|
530
|
-
this.queryData_ = new goog.Uri.QueryData(queryData, null, this.ignoreCase_);
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
return this;
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
/**
|
|
538
|
-
* Sets the URI query.
|
|
539
|
-
* @param {string} newQuery New query value.
|
|
540
|
-
* @param {boolean=} opt_decode Optional param for whether to decode new value.
|
|
541
|
-
* @return {!goog.Uri} Reference to this URI object.
|
|
542
|
-
*/
|
|
543
|
-
goog.Uri.prototype.setQuery = function(newQuery, opt_decode) {
|
|
544
|
-
return this.setQueryData(newQuery, opt_decode);
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* @return {string} The encoded URI query, not including the ?.
|
|
550
|
-
*/
|
|
551
|
-
goog.Uri.prototype.getEncodedQuery = function() {
|
|
552
|
-
return this.queryData_.toString();
|
|
553
|
-
};
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
/**
|
|
557
|
-
* @return {string} The decoded URI query, not including the ?.
|
|
558
|
-
*/
|
|
559
|
-
goog.Uri.prototype.getDecodedQuery = function() {
|
|
560
|
-
return this.queryData_.toDecodedString();
|
|
561
|
-
};
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Returns the query data.
|
|
566
|
-
* @return {!goog.Uri.QueryData} QueryData object.
|
|
567
|
-
*/
|
|
568
|
-
goog.Uri.prototype.getQueryData = function() {
|
|
569
|
-
return this.queryData_;
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
* @return {string} The encoded URI query, not including the ?.
|
|
575
|
-
*
|
|
576
|
-
* Warning: This method, unlike other getter methods, returns encoded
|
|
577
|
-
* value, instead of decoded one.
|
|
578
|
-
*/
|
|
579
|
-
goog.Uri.prototype.getQuery = function() {
|
|
580
|
-
return this.getEncodedQuery();
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* Sets the value of the named query parameters, clearing previous values for
|
|
586
|
-
* that key.
|
|
587
|
-
*
|
|
588
|
-
* @param {string} key The parameter to set.
|
|
589
|
-
* @param {*} value The new value.
|
|
590
|
-
* @return {!goog.Uri} Reference to this URI object.
|
|
591
|
-
*/
|
|
592
|
-
goog.Uri.prototype.setParameterValue = function(key, value) {
|
|
593
|
-
this.enforceReadOnly();
|
|
594
|
-
this.queryData_.set(key, value);
|
|
595
|
-
return this;
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
* Sets the values of the named query parameters, clearing previous values for
|
|
601
|
-
* that key. Not new values will currently be moved to the end of the query
|
|
602
|
-
* string.
|
|
603
|
-
*
|
|
604
|
-
* So, <code>goog.Uri.parse('foo?a=b&c=d&e=f').setParameterValues('c', ['new'])
|
|
605
|
-
* </code> yields <tt>foo?a=b&e=f&c=new</tt>.</p>
|
|
606
|
-
*
|
|
607
|
-
* @param {string} key The parameter to set.
|
|
608
|
-
* @param {*} values The new values. If values is a single
|
|
609
|
-
* string then it will be treated as the sole value.
|
|
610
|
-
* @return {!goog.Uri} Reference to this URI object.
|
|
611
|
-
*/
|
|
612
|
-
goog.Uri.prototype.setParameterValues = function(key, values) {
|
|
613
|
-
this.enforceReadOnly();
|
|
614
|
-
|
|
615
|
-
if (!goog.isArray(values)) {
|
|
616
|
-
values = [String(values)];
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
this.queryData_.setValues(key, values);
|
|
620
|
-
|
|
621
|
-
return this;
|
|
622
|
-
};
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* Returns the value<b>s</b> for a given cgi parameter as a list of decoded
|
|
627
|
-
* query parameter values.
|
|
628
|
-
* @param {string} name The parameter to get values for.
|
|
629
|
-
* @return {!Array<?>} The values for a given cgi parameter as a list of
|
|
630
|
-
* decoded query parameter values.
|
|
631
|
-
*/
|
|
632
|
-
goog.Uri.prototype.getParameterValues = function(name) {
|
|
633
|
-
return this.queryData_.getValues(name);
|
|
634
|
-
};
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* Returns the first value for a given cgi parameter or undefined if the given
|
|
639
|
-
* parameter name does not appear in the query string.
|
|
640
|
-
* @param {string} paramName Unescaped parameter name.
|
|
641
|
-
* @return {string|undefined} The first value for a given cgi parameter or
|
|
642
|
-
* undefined if the given parameter name does not appear in the query
|
|
643
|
-
* string.
|
|
644
|
-
*/
|
|
645
|
-
goog.Uri.prototype.getParameterValue = function(paramName) {
|
|
646
|
-
// NOTE(nicksantos): This type-cast is a lie when
|
|
647
|
-
// preserveParameterTypesCompatibilityFlag is set to true.
|
|
648
|
-
// But this should only be set to true in tests.
|
|
649
|
-
return /** @type {string|undefined} */ (this.queryData_.get(paramName));
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* @return {string} The URI fragment, not including the #.
|
|
655
|
-
*/
|
|
656
|
-
goog.Uri.prototype.getFragment = function() {
|
|
657
|
-
return this.fragment_;
|
|
658
|
-
};
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* Sets the URI fragment.
|
|
663
|
-
* @param {string} newFragment New fragment value.
|
|
664
|
-
* @param {boolean=} opt_decode Optional param for whether to decode new value.
|
|
665
|
-
* @return {!goog.Uri} Reference to this URI object.
|
|
666
|
-
*/
|
|
667
|
-
goog.Uri.prototype.setFragment = function(newFragment, opt_decode) {
|
|
668
|
-
this.enforceReadOnly();
|
|
669
|
-
this.fragment_ = opt_decode ? goog.Uri.decodeOrEmpty_(newFragment) :
|
|
670
|
-
newFragment;
|
|
671
|
-
return this;
|
|
672
|
-
};
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
/**
|
|
676
|
-
* @return {boolean} Whether the URI has a fragment set.
|
|
677
|
-
*/
|
|
678
|
-
goog.Uri.prototype.hasFragment = function() {
|
|
679
|
-
return !!this.fragment_;
|
|
680
|
-
};
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* Returns true if this has the same domain as that of uri2.
|
|
685
|
-
* @param {!goog.Uri} uri2 The URI object to compare to.
|
|
686
|
-
* @return {boolean} true if same domain; false otherwise.
|
|
687
|
-
*/
|
|
688
|
-
goog.Uri.prototype.hasSameDomainAs = function(uri2) {
|
|
689
|
-
return ((!this.hasDomain() && !uri2.hasDomain()) ||
|
|
690
|
-
this.getDomain() == uri2.getDomain()) &&
|
|
691
|
-
((!this.hasPort() && !uri2.hasPort()) ||
|
|
692
|
-
this.getPort() == uri2.getPort());
|
|
693
|
-
};
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
/**
|
|
697
|
-
* Adds a random parameter to the Uri.
|
|
698
|
-
* @return {!goog.Uri} Reference to this Uri object.
|
|
699
|
-
*/
|
|
700
|
-
goog.Uri.prototype.makeUnique = function() {
|
|
701
|
-
this.enforceReadOnly();
|
|
702
|
-
this.setParameterValue(goog.Uri.RANDOM_PARAM, goog.string.getRandomString());
|
|
703
|
-
|
|
704
|
-
return this;
|
|
705
|
-
};
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
* Removes the named query parameter.
|
|
710
|
-
*
|
|
711
|
-
* @param {string} key The parameter to remove.
|
|
712
|
-
* @return {!goog.Uri} Reference to this URI object.
|
|
713
|
-
*/
|
|
714
|
-
goog.Uri.prototype.removeParameter = function(key) {
|
|
715
|
-
this.enforceReadOnly();
|
|
716
|
-
this.queryData_.remove(key);
|
|
717
|
-
return this;
|
|
718
|
-
};
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
/**
|
|
722
|
-
* Sets whether Uri is read only. If this goog.Uri is read-only,
|
|
723
|
-
* enforceReadOnly_ will be called at the start of any function that may modify
|
|
724
|
-
* this Uri.
|
|
725
|
-
* @param {boolean} isReadOnly whether this goog.Uri should be read only.
|
|
726
|
-
* @return {!goog.Uri} Reference to this Uri object.
|
|
727
|
-
*/
|
|
728
|
-
goog.Uri.prototype.setReadOnly = function(isReadOnly) {
|
|
729
|
-
this.isReadOnly_ = isReadOnly;
|
|
730
|
-
return this;
|
|
731
|
-
};
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
/**
|
|
735
|
-
* @return {boolean} Whether the URI is read only.
|
|
736
|
-
*/
|
|
737
|
-
goog.Uri.prototype.isReadOnly = function() {
|
|
738
|
-
return this.isReadOnly_;
|
|
739
|
-
};
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
* Checks if this Uri has been marked as read only, and if so, throws an error.
|
|
744
|
-
* This should be called whenever any modifying function is called.
|
|
745
|
-
*/
|
|
746
|
-
goog.Uri.prototype.enforceReadOnly = function() {
|
|
747
|
-
if (this.isReadOnly_) {
|
|
748
|
-
throw Error('Tried to modify a read-only Uri');
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
/**
|
|
754
|
-
* Sets whether to ignore case.
|
|
755
|
-
* NOTE: If there are already key/value pairs in the QueryData, and
|
|
756
|
-
* ignoreCase_ is set to false, the keys will all be lower-cased.
|
|
757
|
-
* @param {boolean} ignoreCase whether this goog.Uri should ignore case.
|
|
758
|
-
* @return {!goog.Uri} Reference to this Uri object.
|
|
759
|
-
*/
|
|
760
|
-
goog.Uri.prototype.setIgnoreCase = function(ignoreCase) {
|
|
761
|
-
this.ignoreCase_ = ignoreCase;
|
|
762
|
-
if (this.queryData_) {
|
|
763
|
-
this.queryData_.setIgnoreCase(ignoreCase);
|
|
764
|
-
}
|
|
765
|
-
return this;
|
|
766
|
-
};
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
* @return {boolean} Whether to ignore case.
|
|
771
|
-
*/
|
|
772
|
-
goog.Uri.prototype.getIgnoreCase = function() {
|
|
773
|
-
return this.ignoreCase_;
|
|
774
|
-
};
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
//==============================================================================
|
|
778
|
-
// Static members
|
|
779
|
-
//==============================================================================
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* Creates a uri from the string form. Basically an alias of new goog.Uri().
|
|
784
|
-
* If a Uri object is passed to parse then it will return a clone of the object.
|
|
785
|
-
*
|
|
786
|
-
* @param {*} uri Raw URI string or instance of Uri
|
|
787
|
-
* object.
|
|
788
|
-
* @param {boolean=} opt_ignoreCase Whether to ignore the case of parameter
|
|
789
|
-
* names in #getParameterValue.
|
|
790
|
-
* @return {!goog.Uri} The new URI object.
|
|
791
|
-
*/
|
|
792
|
-
goog.Uri.parse = function(uri, opt_ignoreCase) {
|
|
793
|
-
return uri instanceof goog.Uri ?
|
|
794
|
-
uri.clone() : new goog.Uri(uri, opt_ignoreCase);
|
|
795
|
-
};
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
/**
|
|
799
|
-
* Creates a new goog.Uri object from unencoded parts.
|
|
800
|
-
*
|
|
801
|
-
* @param {?string=} opt_scheme Scheme/protocol or full URI to parse.
|
|
802
|
-
* @param {?string=} opt_userInfo username:password.
|
|
803
|
-
* @param {?string=} opt_domain www.google.com.
|
|
804
|
-
* @param {?number=} opt_port 9830.
|
|
805
|
-
* @param {?string=} opt_path /some/path/to/a/file.html.
|
|
806
|
-
* @param {string|goog.Uri.QueryData=} opt_query a=1&b=2.
|
|
807
|
-
* @param {?string=} opt_fragment The fragment without the #.
|
|
808
|
-
* @param {boolean=} opt_ignoreCase Whether to ignore parameter name case in
|
|
809
|
-
* #getParameterValue.
|
|
810
|
-
*
|
|
811
|
-
* @return {!goog.Uri} The new URI object.
|
|
812
|
-
*/
|
|
813
|
-
goog.Uri.create = function(opt_scheme, opt_userInfo, opt_domain, opt_port,
|
|
814
|
-
opt_path, opt_query, opt_fragment, opt_ignoreCase) {
|
|
815
|
-
|
|
816
|
-
var uri = new goog.Uri(null, opt_ignoreCase);
|
|
817
|
-
|
|
818
|
-
// Only set the parts if they are defined and not empty strings.
|
|
819
|
-
opt_scheme && uri.setScheme(opt_scheme);
|
|
820
|
-
opt_userInfo && uri.setUserInfo(opt_userInfo);
|
|
821
|
-
opt_domain && uri.setDomain(opt_domain);
|
|
822
|
-
opt_port && uri.setPort(opt_port);
|
|
823
|
-
opt_path && uri.setPath(opt_path);
|
|
824
|
-
opt_query && uri.setQueryData(opt_query);
|
|
825
|
-
opt_fragment && uri.setFragment(opt_fragment);
|
|
826
|
-
|
|
827
|
-
return uri;
|
|
828
|
-
};
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
/**
|
|
832
|
-
* Resolves a relative Uri against a base Uri, accepting both strings and
|
|
833
|
-
* Uri objects.
|
|
834
|
-
*
|
|
835
|
-
* @param {*} base Base Uri.
|
|
836
|
-
* @param {*} rel Relative Uri.
|
|
837
|
-
* @return {!goog.Uri} Resolved uri.
|
|
838
|
-
*/
|
|
839
|
-
goog.Uri.resolve = function(base, rel) {
|
|
840
|
-
if (!(base instanceof goog.Uri)) {
|
|
841
|
-
base = goog.Uri.parse(base);
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
if (!(rel instanceof goog.Uri)) {
|
|
845
|
-
rel = goog.Uri.parse(rel);
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
return base.resolve(rel);
|
|
849
|
-
};
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
/**
|
|
853
|
-
* Removes dot segments in given path component, as described in
|
|
854
|
-
* RFC 3986, section 5.2.4.
|
|
855
|
-
*
|
|
856
|
-
* @param {string} path A non-empty path component.
|
|
857
|
-
* @return {string} Path component with removed dot segments.
|
|
858
|
-
*/
|
|
859
|
-
goog.Uri.removeDotSegments = function(path) {
|
|
860
|
-
if (path == '..' || path == '.') {
|
|
861
|
-
return '';
|
|
862
|
-
|
|
863
|
-
} else if (!goog.string.contains(path, './') &&
|
|
864
|
-
!goog.string.contains(path, '/.')) {
|
|
865
|
-
// This optimization detects uris which do not contain dot-segments,
|
|
866
|
-
// and as a consequence do not require any processing.
|
|
867
|
-
return path;
|
|
868
|
-
|
|
869
|
-
} else {
|
|
870
|
-
var leadingSlash = goog.string.startsWith(path, '/');
|
|
871
|
-
var segments = path.split('/');
|
|
872
|
-
var out = [];
|
|
873
|
-
|
|
874
|
-
for (var pos = 0; pos < segments.length; ) {
|
|
875
|
-
var segment = segments[pos++];
|
|
876
|
-
|
|
877
|
-
if (segment == '.') {
|
|
878
|
-
if (leadingSlash && pos == segments.length) {
|
|
879
|
-
out.push('');
|
|
880
|
-
}
|
|
881
|
-
} else if (segment == '..') {
|
|
882
|
-
if (out.length > 1 || out.length == 1 && out[0] != '') {
|
|
883
|
-
out.pop();
|
|
884
|
-
}
|
|
885
|
-
if (leadingSlash && pos == segments.length) {
|
|
886
|
-
out.push('');
|
|
887
|
-
}
|
|
888
|
-
} else {
|
|
889
|
-
out.push(segment);
|
|
890
|
-
leadingSlash = true;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
return out.join('/');
|
|
895
|
-
}
|
|
896
|
-
};
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
/**
|
|
900
|
-
* Decodes a value or returns the empty string if it isn't defined or empty.
|
|
901
|
-
* @param {string|undefined} val Value to decode.
|
|
902
|
-
* @param {boolean=} opt_preserveReserved If true, restricted characters will
|
|
903
|
-
* not be decoded.
|
|
904
|
-
* @return {string} Decoded value.
|
|
905
|
-
* @private
|
|
906
|
-
*/
|
|
907
|
-
goog.Uri.decodeOrEmpty_ = function(val, opt_preserveReserved) {
|
|
908
|
-
// Don't use UrlDecode() here because val is not a query parameter.
|
|
909
|
-
if (!val) {
|
|
910
|
-
return '';
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
// decodeURI has the same output for '%2f' and '%252f'. We double encode %25
|
|
914
|
-
// so that we can distinguish between the 2 inputs. This is later undone by
|
|
915
|
-
// removeDoubleEncoding_.
|
|
916
|
-
return opt_preserveReserved ?
|
|
917
|
-
decodeURI(val.replace(/%25/g, '%2525')) : decodeURIComponent(val);
|
|
918
|
-
};
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
/**
|
|
922
|
-
* If unescapedPart is non null, then escapes any characters in it that aren't
|
|
923
|
-
* valid characters in a url and also escapes any special characters that
|
|
924
|
-
* appear in extra.
|
|
925
|
-
*
|
|
926
|
-
* @param {*} unescapedPart The string to encode.
|
|
927
|
-
* @param {RegExp} extra A character set of characters in [\01-\177].
|
|
928
|
-
* @param {boolean=} opt_removeDoubleEncoding If true, remove double percent
|
|
929
|
-
* encoding.
|
|
930
|
-
* @return {?string} null iff unescapedPart == null.
|
|
931
|
-
* @private
|
|
932
|
-
*/
|
|
933
|
-
goog.Uri.encodeSpecialChars_ = function(unescapedPart, extra,
|
|
934
|
-
opt_removeDoubleEncoding) {
|
|
935
|
-
if (goog.isString(unescapedPart)) {
|
|
936
|
-
var encoded = encodeURI(unescapedPart).
|
|
937
|
-
replace(extra, goog.Uri.encodeChar_);
|
|
938
|
-
if (opt_removeDoubleEncoding) {
|
|
939
|
-
// encodeURI double-escapes %XX sequences used to represent restricted
|
|
940
|
-
// characters in some URI components, remove the double escaping here.
|
|
941
|
-
encoded = goog.Uri.removeDoubleEncoding_(encoded);
|
|
942
|
-
}
|
|
943
|
-
return encoded;
|
|
944
|
-
}
|
|
945
|
-
return null;
|
|
946
|
-
};
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
/**
|
|
950
|
-
* Converts a character in [\01-\177] to its unicode character equivalent.
|
|
951
|
-
* @param {string} ch One character string.
|
|
952
|
-
* @return {string} Encoded string.
|
|
953
|
-
* @private
|
|
954
|
-
*/
|
|
955
|
-
goog.Uri.encodeChar_ = function(ch) {
|
|
956
|
-
var n = ch.charCodeAt(0);
|
|
957
|
-
return '%' + ((n >> 4) & 0xf).toString(16) + (n & 0xf).toString(16);
|
|
958
|
-
};
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
/**
|
|
962
|
-
* Removes double percent-encoding from a string.
|
|
963
|
-
* @param {string} doubleEncodedString String
|
|
964
|
-
* @return {string} String with double encoding removed.
|
|
965
|
-
* @private
|
|
966
|
-
*/
|
|
967
|
-
goog.Uri.removeDoubleEncoding_ = function(doubleEncodedString) {
|
|
968
|
-
return doubleEncodedString.replace(/%25([0-9a-fA-F]{2})/g, '%$1');
|
|
969
|
-
};
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
/**
|
|
973
|
-
* Regular expression for characters that are disallowed in the scheme or
|
|
974
|
-
* userInfo part of the URI.
|
|
975
|
-
* @type {RegExp}
|
|
976
|
-
* @private
|
|
977
|
-
*/
|
|
978
|
-
goog.Uri.reDisallowedInSchemeOrUserInfo_ = /[#\/\?@]/g;
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
/**
|
|
982
|
-
* Regular expression for characters that are disallowed in a relative path.
|
|
983
|
-
* Colon is included due to RFC 3986 3.3.
|
|
984
|
-
* @type {RegExp}
|
|
985
|
-
* @private
|
|
986
|
-
*/
|
|
987
|
-
goog.Uri.reDisallowedInRelativePath_ = /[\#\?:]/g;
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
/**
|
|
991
|
-
* Regular expression for characters that are disallowed in an absolute path.
|
|
992
|
-
* @type {RegExp}
|
|
993
|
-
* @private
|
|
994
|
-
*/
|
|
995
|
-
goog.Uri.reDisallowedInAbsolutePath_ = /[\#\?]/g;
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
/**
|
|
999
|
-
* Regular expression for characters that are disallowed in the query.
|
|
1000
|
-
* @type {RegExp}
|
|
1001
|
-
* @private
|
|
1002
|
-
*/
|
|
1003
|
-
goog.Uri.reDisallowedInQuery_ = /[\#\?@]/g;
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
/**
|
|
1007
|
-
* Regular expression for characters that are disallowed in the fragment.
|
|
1008
|
-
* @type {RegExp}
|
|
1009
|
-
* @private
|
|
1010
|
-
*/
|
|
1011
|
-
goog.Uri.reDisallowedInFragment_ = /#/g;
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
/**
|
|
1015
|
-
* Checks whether two URIs have the same domain.
|
|
1016
|
-
* @param {string} uri1String First URI string.
|
|
1017
|
-
* @param {string} uri2String Second URI string.
|
|
1018
|
-
* @return {boolean} true if the two URIs have the same domain; false otherwise.
|
|
1019
|
-
*/
|
|
1020
|
-
goog.Uri.haveSameDomain = function(uri1String, uri2String) {
|
|
1021
|
-
// Differs from goog.uri.utils.haveSameDomain, since this ignores scheme.
|
|
1022
|
-
// TODO(gboyer): Have this just call goog.uri.util.haveSameDomain.
|
|
1023
|
-
var pieces1 = goog.uri.utils.split(uri1String);
|
|
1024
|
-
var pieces2 = goog.uri.utils.split(uri2String);
|
|
1025
|
-
return pieces1[goog.uri.utils.ComponentIndex.DOMAIN] ==
|
|
1026
|
-
pieces2[goog.uri.utils.ComponentIndex.DOMAIN] &&
|
|
1027
|
-
pieces1[goog.uri.utils.ComponentIndex.PORT] ==
|
|
1028
|
-
pieces2[goog.uri.utils.ComponentIndex.PORT];
|
|
1029
|
-
};
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
/**
|
|
1034
|
-
* Class used to represent URI query parameters. It is essentially a hash of
|
|
1035
|
-
* name-value pairs, though a name can be present more than once.
|
|
1036
|
-
*
|
|
1037
|
-
* Has the same interface as the collections in goog.structs.
|
|
1038
|
-
*
|
|
1039
|
-
* @param {?string=} opt_query Optional encoded query string to parse into
|
|
1040
|
-
* the object.
|
|
1041
|
-
* @param {goog.Uri=} opt_uri Optional uri object that should have its
|
|
1042
|
-
* cache invalidated when this object updates. Deprecated -- this
|
|
1043
|
-
* is no longer required.
|
|
1044
|
-
* @param {boolean=} opt_ignoreCase If true, ignore the case of the parameter
|
|
1045
|
-
* name in #get.
|
|
1046
|
-
* @constructor
|
|
1047
|
-
* @struct
|
|
1048
|
-
* @final
|
|
1049
|
-
*/
|
|
1050
|
-
goog.Uri.QueryData = function(opt_query, opt_uri, opt_ignoreCase) {
|
|
1051
|
-
/**
|
|
1052
|
-
* The map containing name/value or name/array-of-values pairs.
|
|
1053
|
-
* May be null if it requires parsing from the query string.
|
|
1054
|
-
*
|
|
1055
|
-
* We need to use a Map because we cannot guarantee that the key names will
|
|
1056
|
-
* not be problematic for IE.
|
|
1057
|
-
*
|
|
1058
|
-
* @private {goog.structs.Map<string, !Array<*>>}
|
|
1059
|
-
*/
|
|
1060
|
-
this.keyMap_ = null;
|
|
1061
|
-
|
|
1062
|
-
/**
|
|
1063
|
-
* The number of params, or null if it requires computing.
|
|
1064
|
-
* @private {?number}
|
|
1065
|
-
*/
|
|
1066
|
-
this.count_ = null;
|
|
1067
|
-
|
|
1068
|
-
/**
|
|
1069
|
-
* Encoded query string, or null if it requires computing from the key map.
|
|
1070
|
-
* @private {?string}
|
|
1071
|
-
*/
|
|
1072
|
-
this.encodedQuery_ = opt_query || null;
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* If true, ignore the case of the parameter name in #get.
|
|
1076
|
-
* @private {boolean}
|
|
1077
|
-
*/
|
|
1078
|
-
this.ignoreCase_ = !!opt_ignoreCase;
|
|
1079
|
-
};
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
/**
|
|
1083
|
-
* If the underlying key map is not yet initialized, it parses the
|
|
1084
|
-
* query string and fills the map with parsed data.
|
|
1085
|
-
* @private
|
|
1086
|
-
*/
|
|
1087
|
-
goog.Uri.QueryData.prototype.ensureKeyMapInitialized_ = function() {
|
|
1088
|
-
if (!this.keyMap_) {
|
|
1089
|
-
this.keyMap_ = new goog.structs.Map();
|
|
1090
|
-
this.count_ = 0;
|
|
1091
|
-
if (this.encodedQuery_) {
|
|
1092
|
-
var self = this;
|
|
1093
|
-
goog.uri.utils.parseQueryData(this.encodedQuery_, function(name, value) {
|
|
1094
|
-
self.add(goog.string.urlDecode(name), value);
|
|
1095
|
-
});
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
};
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
/**
|
|
1102
|
-
* Creates a new query data instance from a map of names and values.
|
|
1103
|
-
*
|
|
1104
|
-
* @param {!goog.structs.Map<string, ?>|!Object} map Map of string parameter
|
|
1105
|
-
* names to parameter value. If parameter value is an array, it is
|
|
1106
|
-
* treated as if the key maps to each individual value in the
|
|
1107
|
-
* array.
|
|
1108
|
-
* @param {goog.Uri=} opt_uri URI object that should have its cache
|
|
1109
|
-
* invalidated when this object updates.
|
|
1110
|
-
* @param {boolean=} opt_ignoreCase If true, ignore the case of the parameter
|
|
1111
|
-
* name in #get.
|
|
1112
|
-
* @return {!goog.Uri.QueryData} The populated query data instance.
|
|
1113
|
-
*/
|
|
1114
|
-
goog.Uri.QueryData.createFromMap = function(map, opt_uri, opt_ignoreCase) {
|
|
1115
|
-
var keys = goog.structs.getKeys(map);
|
|
1116
|
-
if (typeof keys == 'undefined') {
|
|
1117
|
-
throw Error('Keys are undefined');
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
var queryData = new goog.Uri.QueryData(null, null, opt_ignoreCase);
|
|
1121
|
-
var values = goog.structs.getValues(map);
|
|
1122
|
-
for (var i = 0; i < keys.length; i++) {
|
|
1123
|
-
var key = keys[i];
|
|
1124
|
-
var value = values[i];
|
|
1125
|
-
if (!goog.isArray(value)) {
|
|
1126
|
-
queryData.add(key, value);
|
|
1127
|
-
} else {
|
|
1128
|
-
queryData.setValues(key, value);
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
return queryData;
|
|
1132
|
-
};
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
/**
|
|
1136
|
-
* Creates a new query data instance from parallel arrays of parameter names
|
|
1137
|
-
* and values. Allows for duplicate parameter names. Throws an error if the
|
|
1138
|
-
* lengths of the arrays differ.
|
|
1139
|
-
*
|
|
1140
|
-
* @param {!Array<string>} keys Parameter names.
|
|
1141
|
-
* @param {!Array<?>} values Parameter values.
|
|
1142
|
-
* @param {goog.Uri=} opt_uri URI object that should have its cache
|
|
1143
|
-
* invalidated when this object updates.
|
|
1144
|
-
* @param {boolean=} opt_ignoreCase If true, ignore the case of the parameter
|
|
1145
|
-
* name in #get.
|
|
1146
|
-
* @return {!goog.Uri.QueryData} The populated query data instance.
|
|
1147
|
-
*/
|
|
1148
|
-
goog.Uri.QueryData.createFromKeysValues = function(
|
|
1149
|
-
keys, values, opt_uri, opt_ignoreCase) {
|
|
1150
|
-
if (keys.length != values.length) {
|
|
1151
|
-
throw Error('Mismatched lengths for keys/values');
|
|
1152
|
-
}
|
|
1153
|
-
var queryData = new goog.Uri.QueryData(null, null, opt_ignoreCase);
|
|
1154
|
-
for (var i = 0; i < keys.length; i++) {
|
|
1155
|
-
queryData.add(keys[i], values[i]);
|
|
1156
|
-
}
|
|
1157
|
-
return queryData;
|
|
1158
|
-
};
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
/**
|
|
1162
|
-
* @return {?number} The number of parameters.
|
|
1163
|
-
*/
|
|
1164
|
-
goog.Uri.QueryData.prototype.getCount = function() {
|
|
1165
|
-
this.ensureKeyMapInitialized_();
|
|
1166
|
-
return this.count_;
|
|
1167
|
-
};
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
/**
|
|
1171
|
-
* Adds a key value pair.
|
|
1172
|
-
* @param {string} key Name.
|
|
1173
|
-
* @param {*} value Value.
|
|
1174
|
-
* @return {!goog.Uri.QueryData} Instance of this object.
|
|
1175
|
-
*/
|
|
1176
|
-
goog.Uri.QueryData.prototype.add = function(key, value) {
|
|
1177
|
-
this.ensureKeyMapInitialized_();
|
|
1178
|
-
this.invalidateCache_();
|
|
1179
|
-
|
|
1180
|
-
key = this.getKeyName_(key);
|
|
1181
|
-
var values = this.keyMap_.get(key);
|
|
1182
|
-
if (!values) {
|
|
1183
|
-
this.keyMap_.set(key, (values = []));
|
|
1184
|
-
}
|
|
1185
|
-
values.push(value);
|
|
1186
|
-
this.count_++;
|
|
1187
|
-
return this;
|
|
1188
|
-
};
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* Removes all the params with the given key.
|
|
1193
|
-
* @param {string} key Name.
|
|
1194
|
-
* @return {boolean} Whether any parameter was removed.
|
|
1195
|
-
*/
|
|
1196
|
-
goog.Uri.QueryData.prototype.remove = function(key) {
|
|
1197
|
-
this.ensureKeyMapInitialized_();
|
|
1198
|
-
|
|
1199
|
-
key = this.getKeyName_(key);
|
|
1200
|
-
if (this.keyMap_.containsKey(key)) {
|
|
1201
|
-
this.invalidateCache_();
|
|
1202
|
-
|
|
1203
|
-
// Decrement parameter count.
|
|
1204
|
-
this.count_ -= this.keyMap_.get(key).length;
|
|
1205
|
-
return this.keyMap_.remove(key);
|
|
1206
|
-
}
|
|
1207
|
-
return false;
|
|
1208
|
-
};
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
/**
|
|
1212
|
-
* Clears the parameters.
|
|
1213
|
-
*/
|
|
1214
|
-
goog.Uri.QueryData.prototype.clear = function() {
|
|
1215
|
-
this.invalidateCache_();
|
|
1216
|
-
this.keyMap_ = null;
|
|
1217
|
-
this.count_ = 0;
|
|
1218
|
-
};
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
/**
|
|
1222
|
-
* @return {boolean} Whether we have any parameters.
|
|
1223
|
-
*/
|
|
1224
|
-
goog.Uri.QueryData.prototype.isEmpty = function() {
|
|
1225
|
-
this.ensureKeyMapInitialized_();
|
|
1226
|
-
return this.count_ == 0;
|
|
1227
|
-
};
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
/**
|
|
1231
|
-
* Whether there is a parameter with the given name
|
|
1232
|
-
* @param {string} key The parameter name to check for.
|
|
1233
|
-
* @return {boolean} Whether there is a parameter with the given name.
|
|
1234
|
-
*/
|
|
1235
|
-
goog.Uri.QueryData.prototype.containsKey = function(key) {
|
|
1236
|
-
this.ensureKeyMapInitialized_();
|
|
1237
|
-
key = this.getKeyName_(key);
|
|
1238
|
-
return this.keyMap_.containsKey(key);
|
|
1239
|
-
};
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
/**
|
|
1243
|
-
* Whether there is a parameter with the given value.
|
|
1244
|
-
* @param {*} value The value to check for.
|
|
1245
|
-
* @return {boolean} Whether there is a parameter with the given value.
|
|
1246
|
-
*/
|
|
1247
|
-
goog.Uri.QueryData.prototype.containsValue = function(value) {
|
|
1248
|
-
// NOTE(arv): This solution goes through all the params even if it was the
|
|
1249
|
-
// first param. We can get around this by not reusing code or by switching to
|
|
1250
|
-
// iterators.
|
|
1251
|
-
var vals = this.getValues();
|
|
1252
|
-
return goog.array.contains(vals, value);
|
|
1253
|
-
};
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
/**
|
|
1257
|
-
* Returns all the keys of the parameters. If a key is used multiple times
|
|
1258
|
-
* it will be included multiple times in the returned array
|
|
1259
|
-
* @return {!Array<string>} All the keys of the parameters.
|
|
1260
|
-
*/
|
|
1261
|
-
goog.Uri.QueryData.prototype.getKeys = function() {
|
|
1262
|
-
this.ensureKeyMapInitialized_();
|
|
1263
|
-
// We need to get the values to know how many keys to add.
|
|
1264
|
-
var vals = /** @type {!Array<*>} */ (this.keyMap_.getValues());
|
|
1265
|
-
var keys = this.keyMap_.getKeys();
|
|
1266
|
-
var rv = [];
|
|
1267
|
-
for (var i = 0; i < keys.length; i++) {
|
|
1268
|
-
var val = vals[i];
|
|
1269
|
-
for (var j = 0; j < val.length; j++) {
|
|
1270
|
-
rv.push(keys[i]);
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
return rv;
|
|
1274
|
-
};
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
/**
|
|
1278
|
-
* Returns all the values of the parameters with the given name. If the query
|
|
1279
|
-
* data has no such key this will return an empty array. If no key is given
|
|
1280
|
-
* all values wil be returned.
|
|
1281
|
-
* @param {string=} opt_key The name of the parameter to get the values for.
|
|
1282
|
-
* @return {!Array<?>} All the values of the parameters with the given name.
|
|
1283
|
-
*/
|
|
1284
|
-
goog.Uri.QueryData.prototype.getValues = function(opt_key) {
|
|
1285
|
-
this.ensureKeyMapInitialized_();
|
|
1286
|
-
var rv = [];
|
|
1287
|
-
if (goog.isString(opt_key)) {
|
|
1288
|
-
if (this.containsKey(opt_key)) {
|
|
1289
|
-
rv = goog.array.concat(rv, this.keyMap_.get(this.getKeyName_(opt_key)));
|
|
1290
|
-
}
|
|
1291
|
-
} else {
|
|
1292
|
-
// Return all values.
|
|
1293
|
-
var values = this.keyMap_.getValues();
|
|
1294
|
-
for (var i = 0; i < values.length; i++) {
|
|
1295
|
-
rv = goog.array.concat(rv, values[i]);
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
return rv;
|
|
1299
|
-
};
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
/**
|
|
1303
|
-
* Sets a key value pair and removes all other keys with the same value.
|
|
1304
|
-
*
|
|
1305
|
-
* @param {string} key Name.
|
|
1306
|
-
* @param {*} value Value.
|
|
1307
|
-
* @return {!goog.Uri.QueryData} Instance of this object.
|
|
1308
|
-
*/
|
|
1309
|
-
goog.Uri.QueryData.prototype.set = function(key, value) {
|
|
1310
|
-
this.ensureKeyMapInitialized_();
|
|
1311
|
-
this.invalidateCache_();
|
|
1312
|
-
|
|
1313
|
-
// TODO(chrishenry): This could be better written as
|
|
1314
|
-
// this.remove(key), this.add(key, value), but that would reorder
|
|
1315
|
-
// the key (since the key is first removed and then added at the
|
|
1316
|
-
// end) and we would have to fix unit tests that depend on key
|
|
1317
|
-
// ordering.
|
|
1318
|
-
key = this.getKeyName_(key);
|
|
1319
|
-
if (this.containsKey(key)) {
|
|
1320
|
-
this.count_ -= this.keyMap_.get(key).length;
|
|
1321
|
-
}
|
|
1322
|
-
this.keyMap_.set(key, [value]);
|
|
1323
|
-
this.count_++;
|
|
1324
|
-
return this;
|
|
1325
|
-
};
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
/**
|
|
1329
|
-
* Returns the first value associated with the key. If the query data has no
|
|
1330
|
-
* such key this will return undefined or the optional default.
|
|
1331
|
-
* @param {string} key The name of the parameter to get the value for.
|
|
1332
|
-
* @param {*=} opt_default The default value to return if the query data
|
|
1333
|
-
* has no such key.
|
|
1334
|
-
* @return {*} The first string value associated with the key, or opt_default
|
|
1335
|
-
* if there's no value.
|
|
1336
|
-
*/
|
|
1337
|
-
goog.Uri.QueryData.prototype.get = function(key, opt_default) {
|
|
1338
|
-
var values = key ? this.getValues(key) : [];
|
|
1339
|
-
if (goog.Uri.preserveParameterTypesCompatibilityFlag) {
|
|
1340
|
-
return values.length > 0 ? values[0] : opt_default;
|
|
1341
|
-
} else {
|
|
1342
|
-
return values.length > 0 ? String(values[0]) : opt_default;
|
|
1343
|
-
}
|
|
1344
|
-
};
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
/**
|
|
1348
|
-
* Sets the values for a key. If the key already exists, this will
|
|
1349
|
-
* override all of the existing values that correspond to the key.
|
|
1350
|
-
* @param {string} key The key to set values for.
|
|
1351
|
-
* @param {!Array<?>} values The values to set.
|
|
1352
|
-
*/
|
|
1353
|
-
goog.Uri.QueryData.prototype.setValues = function(key, values) {
|
|
1354
|
-
this.remove(key);
|
|
1355
|
-
|
|
1356
|
-
if (values.length > 0) {
|
|
1357
|
-
this.invalidateCache_();
|
|
1358
|
-
this.keyMap_.set(this.getKeyName_(key), goog.array.clone(values));
|
|
1359
|
-
this.count_ += values.length;
|
|
1360
|
-
}
|
|
1361
|
-
};
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
/**
|
|
1365
|
-
* @return {string} Encoded query string.
|
|
1366
|
-
* @override
|
|
1367
|
-
*/
|
|
1368
|
-
goog.Uri.QueryData.prototype.toString = function() {
|
|
1369
|
-
if (this.encodedQuery_) {
|
|
1370
|
-
return this.encodedQuery_;
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
if (!this.keyMap_) {
|
|
1374
|
-
return '';
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
|
-
var sb = [];
|
|
1378
|
-
|
|
1379
|
-
// In the past, we use this.getKeys() and this.getVals(), but that
|
|
1380
|
-
// generates a lot of allocations as compared to simply iterating
|
|
1381
|
-
// over the keys.
|
|
1382
|
-
var keys = this.keyMap_.getKeys();
|
|
1383
|
-
for (var i = 0; i < keys.length; i++) {
|
|
1384
|
-
var key = keys[i];
|
|
1385
|
-
var encodedKey = goog.string.urlEncode(key);
|
|
1386
|
-
var val = this.getValues(key);
|
|
1387
|
-
for (var j = 0; j < val.length; j++) {
|
|
1388
|
-
var param = encodedKey;
|
|
1389
|
-
// Ensure that null and undefined are encoded into the url as
|
|
1390
|
-
// literal strings.
|
|
1391
|
-
if (val[j] !== '') {
|
|
1392
|
-
param += '=' + goog.string.urlEncode(val[j]);
|
|
1393
|
-
}
|
|
1394
|
-
sb.push(param);
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
return this.encodedQuery_ = sb.join('&');
|
|
1399
|
-
};
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
/**
|
|
1403
|
-
* @return {string} Decoded query string.
|
|
1404
|
-
*/
|
|
1405
|
-
goog.Uri.QueryData.prototype.toDecodedString = function() {
|
|
1406
|
-
return goog.Uri.decodeOrEmpty_(this.toString());
|
|
1407
|
-
};
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
/**
|
|
1411
|
-
* Invalidate the cache.
|
|
1412
|
-
* @private
|
|
1413
|
-
*/
|
|
1414
|
-
goog.Uri.QueryData.prototype.invalidateCache_ = function() {
|
|
1415
|
-
this.encodedQuery_ = null;
|
|
1416
|
-
};
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
/**
|
|
1420
|
-
* Removes all keys that are not in the provided list. (Modifies this object.)
|
|
1421
|
-
* @param {Array<string>} keys The desired keys.
|
|
1422
|
-
* @return {!goog.Uri.QueryData} a reference to this object.
|
|
1423
|
-
*/
|
|
1424
|
-
goog.Uri.QueryData.prototype.filterKeys = function(keys) {
|
|
1425
|
-
this.ensureKeyMapInitialized_();
|
|
1426
|
-
this.keyMap_.forEach(
|
|
1427
|
-
function(value, key) {
|
|
1428
|
-
if (!goog.array.contains(keys, key)) {
|
|
1429
|
-
this.remove(key);
|
|
1430
|
-
}
|
|
1431
|
-
}, this);
|
|
1432
|
-
return this;
|
|
1433
|
-
};
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
/**
|
|
1437
|
-
* Clone the query data instance.
|
|
1438
|
-
* @return {!goog.Uri.QueryData} New instance of the QueryData object.
|
|
1439
|
-
*/
|
|
1440
|
-
goog.Uri.QueryData.prototype.clone = function() {
|
|
1441
|
-
var rv = new goog.Uri.QueryData();
|
|
1442
|
-
rv.encodedQuery_ = this.encodedQuery_;
|
|
1443
|
-
if (this.keyMap_) {
|
|
1444
|
-
rv.keyMap_ = this.keyMap_.clone();
|
|
1445
|
-
rv.count_ = this.count_;
|
|
1446
|
-
}
|
|
1447
|
-
return rv;
|
|
1448
|
-
};
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
/**
|
|
1452
|
-
* Helper function to get the key name from a JavaScript object. Converts
|
|
1453
|
-
* the object to a string, and to lower case if necessary.
|
|
1454
|
-
* @private
|
|
1455
|
-
* @param {*} arg The object to get a key name from.
|
|
1456
|
-
* @return {string} valid key name which can be looked up in #keyMap_.
|
|
1457
|
-
*/
|
|
1458
|
-
goog.Uri.QueryData.prototype.getKeyName_ = function(arg) {
|
|
1459
|
-
var keyName = String(arg);
|
|
1460
|
-
if (this.ignoreCase_) {
|
|
1461
|
-
keyName = keyName.toLowerCase();
|
|
1462
|
-
}
|
|
1463
|
-
return keyName;
|
|
1464
|
-
};
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
/**
|
|
1468
|
-
* Ignore case in parameter names.
|
|
1469
|
-
* NOTE: If there are already key/value pairs in the QueryData, and
|
|
1470
|
-
* ignoreCase_ is set to false, the keys will all be lower-cased.
|
|
1471
|
-
* @param {boolean} ignoreCase whether this goog.Uri should ignore case.
|
|
1472
|
-
*/
|
|
1473
|
-
goog.Uri.QueryData.prototype.setIgnoreCase = function(ignoreCase) {
|
|
1474
|
-
var resetKeys = ignoreCase && !this.ignoreCase_;
|
|
1475
|
-
if (resetKeys) {
|
|
1476
|
-
this.ensureKeyMapInitialized_();
|
|
1477
|
-
this.invalidateCache_();
|
|
1478
|
-
this.keyMap_.forEach(
|
|
1479
|
-
function(value, key) {
|
|
1480
|
-
var lowerCase = key.toLowerCase();
|
|
1481
|
-
if (key != lowerCase) {
|
|
1482
|
-
this.remove(key);
|
|
1483
|
-
this.setValues(lowerCase, value);
|
|
1484
|
-
}
|
|
1485
|
-
}, this);
|
|
1486
|
-
}
|
|
1487
|
-
this.ignoreCase_ = ignoreCase;
|
|
1488
|
-
};
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
/**
|
|
1492
|
-
* Extends a query data object with another query data or map like object. This
|
|
1493
|
-
* operates 'in-place', it does not create a new QueryData object.
|
|
1494
|
-
*
|
|
1495
|
-
* @param {...(goog.Uri.QueryData|goog.structs.Map<?, ?>|Object)} var_args
|
|
1496
|
-
* The object from which key value pairs will be copied.
|
|
1497
|
-
*/
|
|
1498
|
-
goog.Uri.QueryData.prototype.extend = function(var_args) {
|
|
1499
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
1500
|
-
var data = arguments[i];
|
|
1501
|
-
goog.structs.forEach(data,
|
|
1502
|
-
/** @this {goog.Uri.QueryData} */
|
|
1503
|
-
function(value, key) {
|
|
1504
|
-
this.add(key, value);
|
|
1505
|
-
}, this);
|
|
1506
|
-
}
|
|
1507
|
-
};
|