10 examples of 'urlsearchparams angular2' in JavaScript

Every line of 'urlsearchparams angular2' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
160private buildUrlSearchParams(params: any): URLSearchParams {
161 var searchParams = new URLSearchParams();
162 for (var key in params) {
163 searchParams.append(key, params[key])
164 }
165 return searchParams;
166}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

88protected initializeSearchParams(searchParams?): URLSearchParams {
89 const initializedSearchParams = this.getDefaultSearchParams();
90 searchParams = searchParams || {};
91 for (let name in searchParams) {
92 if (searchParams.hasOwnProperty(name)) {
93 initializedSearchParams.set(name, searchParams[name]);
94 }
95 }
96 return initializedSearchParams;
97}
60function findSearchParams(url: string): URLSearchParams {
61 if (url == null) return null;
62 const searchs = url.split('?')[1];
63 if (searchs == null) return null;
64 return new URLSearchParams(searchs);
65}
94export function buildSearchURLQuery(query: string): string {
95 const searchParams = new URLSearchParams()
96 searchParams.set('q', query)
97 return searchParams
98 .toString()
99 .replace(/%2F/g, '/')
100 .replace(/%3A/g, ':')
101}
56private removeQueryParamFromUrl_(url: string): string {
57 const queryStartIdx = url.indexOf(this.queryParamStart_) + 1;
58 const rawUrl = url.substring(0, queryStartIdx - 1);
59
60 const paramMap = this.getQueryParams_(url);
61 if (paramMap[SEARCH_QUERY_STATE_PARAM]) {
62 delete paramMap[SEARCH_QUERY_STATE_PARAM];
63 }
64
65 const queryParams =
66 Object.keys(paramMap).map(key => `${key}=${paramMap[key]}`).join(this.queryParamSeparator_);
67 return `${rawUrl}${this.queryParamStart_}${queryParams}`;
68}
68get search(): URLSearchParams { return this.params; }
37private static createSearchParamsFromObject(query: Object): URLSearchParams {
38 let params = new URLSearchParams();
39 for (let key in query) {
40 params.append(key, query[key]);
41 }
42 return params;
43}
14export function getParams() {
15 return new URLSearchParams(
16 typeof window == 'object' ? window.location.search : ''
17 )
18}
377function generateURLSearchFrom(params) {
378 var keys = Object.keys(params);
379 if (keys.length == 0) {
380 return "";
381 } else {
382 return "?" + keys.map(function(k) {
383 if (params[k] != 'undefined') {
384 return "" + k + "=" + encodeURIComponent(params[k]);
385 } else {
386 return "" + k;
387 }
388 }).join("&");
389 }
390}
37export function interactiveParseSearchURLQuery(query: string): string | undefined {
38 const searchParams = new URLSearchParams(query)
39 const finalQueryParts = []
40 for (const suggestionType of Object.keys(SuggestionTypes)) {
41 for (const filterValue of searchParams.getAll(suggestionType)) {
42 finalQueryParts.push(`${suggestionType}:${filterValue}`)
43 }
44 }
45
46 const querySearchParams = searchParams.get('q')
47
48 if (querySearchParams) {
49 finalQueryParts.push(querySearchParams)
50 }
51
52 if (finalQueryParts.length > 0) {
53 return finalQueryParts.join(' ')
54 }
55
56 return undefined
57}

Related snippets