Skip to content

Commit

Permalink
feat(core)!: Remove urlEncode method (#14783)
Browse files Browse the repository at this point in the history
ref: #14268

Deprecation PR:
#14406

Removes `urlEncode`. This has no replacement.
  • Loading branch information
AbhiPrasad authored Dec 18, 2024
1 parent 2628e40 commit b7730d8
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 40 deletions.
1 change: 1 addition & 0 deletions docs/migration/v8-to-v9.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ It will be removed in a future major version.
- The `validSeverityLevels` export has been removed. There is no replacement.
- The `arrayify` export has been removed. There is no replacement.
- The `flatten` export has been removed. There is no replacement.
- The `urlEncode` method has been removed. There is no replacement.

### `@sentry/nestjs`

Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/utils-hoist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ export {
getOriginalFunction,
markFunctionWrapped,
objectify,
// eslint-disable-next-line deprecation/deprecation
urlEncode,
} from './object';
export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './path';
export { makePromiseBuffer } from './promisebuffer';
Expand Down
15 changes: 0 additions & 15 deletions packages/core/src/utils-hoist/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,6 @@ export function getOriginalFunction<T extends Function>(func: WrappedFunction<T>
return func.__sentry_original__;
}

/**
* Encodes given object into url-friendly format
*
* @param object An object that contains serializable values
* @returns string Encoded
*
* @deprecated This function is deprecated and will be removed in the next major version of the SDK.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function urlEncode(object: { [key: string]: any }): string {
return Object.entries(object)
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
.join('&');
}

/**
* Transforms any `Error` or `Event` into a plain object with all of their enumerable properties, and some of their
* non-enumerable properties attached.
Expand Down
18 changes: 0 additions & 18 deletions packages/core/test/utils-hoist/object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
fill,
markFunctionWrapped,
objectify,
urlEncode,
} from '../../src/utils-hoist/object';
import { testOnlyIfNodeVersionAtLeast } from './testutils';

Expand Down Expand Up @@ -128,23 +127,6 @@ describe('fill()', () => {
});
});

describe('urlEncode()', () => {
test('returns empty string for empty object input', () => {
// eslint-disable-next-line deprecation/deprecation
expect(urlEncode({})).toEqual('');
});

test('returns single key/value pair joined with = sign', () => {
// eslint-disable-next-line deprecation/deprecation
expect(urlEncode({ foo: 'bar' })).toEqual('foo=bar');
});

test('returns multiple key/value pairs joined together with & sign', () => {
// eslint-disable-next-line deprecation/deprecation
expect(urlEncode({ foo: 'bar', pickle: 'rick', morty: '4 2' })).toEqual('foo=bar&pickle=rick&morty=4%202');
});
});

describe('extractExceptionKeysForMessage()', () => {
test('no keys', () => {
expect(extractExceptionKeysForMessage({}, 10)).toEqual('[object has no keys]');
Expand Down
5 changes: 0 additions & 5 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ import {
triggerHandlers as triggerHandlers_imported,
truncate as truncate_imported,
updateRateLimits as updateRateLimits_imported,
urlEncode as urlEncode_imported,
uuid4 as uuid4_imported,
vercelWaitUntil as vercelWaitUntil_imported,
watchdogTimer as watchdogTimer_imported,
Expand Down Expand Up @@ -605,10 +604,6 @@ export const memoBuilder = memoBuilder_imported;
/** @deprecated Import from `@sentry/core` instead. */
export const normalizeUrlToBase = normalizeUrlToBase_imported;

/** @deprecated Import from `@sentry/core` instead. */
// eslint-disable-next-line deprecation/deprecation
export const urlEncode = urlEncode_imported;

/** @deprecated Import from `@sentry/core` instead. */
// eslint-disable-next-line deprecation/deprecation
export const extractPathForTransaction = extractPathForTransaction_imported;
Expand Down

0 comments on commit b7730d8

Please sign in to comment.