All Downloads are FREE. Search and download functionalities are using the official Maven repository.

typescript-angular.encoder.mustache Maven / Gradle / Ivy

There is a newer version: 3.0.0-rc1
Show newest version
{{#useHttpClient}}
    import { HttpUrlEncodingCodec } from '@angular/common/http';
{{/useHttpClient}}
{{^useHttpClient}}
    import { QueryEncoder } from '@angular/http';
{{/useHttpClient}}

{{#useHttpClient}}
/**
* CustomHttpUrlEncodingCodec
* Fix plus sign (+) not encoding, so sent as blank space
* See: https://github.com/angular/angular/issues/11058#issuecomment-247367318
*/
export class CustomHttpUrlEncodingCodec extends HttpUrlEncodingCodec {
    override encodeKey(k: string): string {
        k = super.encodeKey(k);
        return k.replace(/\+/gi, '%2B');
    }
    override encodeValue(v: string): string {
        v = super.encodeValue(v);
        return v.replace(/\+/gi, '%2B');
    }
}
{{/useHttpClient}}
{{^useHttpClient}}
/**
* CustomQueryEncoderHelper
* Fix plus sign (+) not encoding, so sent as blank space
* See: https://github.com/angular/angular/issues/11058#issuecomment-247367318
*/
export class CustomQueryEncoderHelper extends QueryEncoder {
    encodeKey(k: string): string {
        k = super.encodeKey(k);
        return k.replace(/\+/gi, '%2B');
    }
    encodeValue(v: string): string {
        v = super.encodeValue(v);
        return v.replace(/\+/gi, '%2B');
    }
}
{{/useHttpClient}}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy