• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Common Library Subsystem Changelog
2
3## cl.commonlibrary.1 URLParams Class Changes
4The constructor function of the **URLParams** class in the URL module of the common library subsystem is changed.
5
6Specifically, **constructor(init?: string[][] | Record<string, string> | string | URLSearchParams)** is changed to **constructor(init?: string[][] | Record<string, string> | string | URLParams)**, and the parameter type is changed from **URLSearchParams** to **URLParams**.
7
8You need to adapt your application.
9
10**Change Impacts**
11
12JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.
13
14**Key API/Component Changes**
15
16| Module                   | Class               | Method/Attribute/Enum/Constant                                         | Change Type|
17| :------------------------ | ------------------- | ------------------------------------------------------------ | -------- |
18| @ohos.url        | URLParams         | constructor(string[][] \| Record&lt;string, string&gt; \| string \| URLSearchParams) | Deleted |
19| @ohos.url         | URLParams       | constructor(string[][] \| Record&lt;string, string&gt; \| string \| URLParams)| Changed |
20
21**Adaptation Guide**
22
23The following illustrates how to create a **URLParams** object in your application.
24
25Example:
26
27```ts
28import url from '@ohos.url'
29try {
30    let params1 = new Url.URLParams('?user=abc&query=xyz')
31    let params2 = new Url.URLParams(params1)
32    var result= params2.toString()
33    console.log(result) //"user=abc&query=xyz"
34} catch (err) {
35    console.error(`Fail to ceate URLParams.codeis${err.code},message is ${err.message}`);
36}
37```
38## cl.commonlibrary.2 URL Attribute Changes of URLParams Class APIs
39The URL attributes of the URL module in the common library subsystem are changed.
40
41Specifically, the **searchParams: URLSearchParams** attribute is deprecated, and the **params: URLParams** attribute is added.
42
43You need to adapt your application.
44
45 **Change Impacts**
46
47JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.
48
49**Key API/Component Changes**
50
51| Module                   | Class               | Method/Attribute/Enum/Constant                                         | Change Type|
52| :------------------------ | ------------------- | ------------------------------------------------------------ | -------- |
53| @ohos.url        | URL         |  searchParams: URLSearchParams; |Deprecated (in API version 9)<br>   |
54| @ohos.url        | URL         |  params: URLParams; | Added    |
55
56**Adaptation Guide**
57
58The following illustrates how to create a **URLParams** object in your application.
59
60Example:
61
62```ts
63import url from '@ohos.url'
64let that = new Url.URL('http://username:password@host:8080/directory/file?Hello=china#qwer=da')
65let params = that.URLParams
66var result = params.toString()
67console.log(result) //%E4%BD%A0%E5%A5%BD=china
68```
69