all files / app/utils/ query-encoder-helper.ts

63.64% Statements 7/11
100% Branches 0/0
16.67% Functions 1/6
60% Lines 6/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                              1× 1×       1×     1×     1×     1×  
///<reference path="../../../node_modules/@angular/common/http/src/params.d.ts"/>
/* Copyright CloudLinux Zug GmbH 2010-2017 All Rights Reserved
 *
 * Licensed under CLOUD LINUX LICENSE AGREEMENT
 * http://cloudlinux.com/docs/LICENSE.TXT
 */
 
/*
 * CustomQueryEncoderHelper
 * Fix plus sign (+) not encoding, so sent as blank space
 * See: https://github.com/angular/angular/issues/11058#issuecomment-247367318
 */
 
import {HttpParameterCodec} from '@angular/common/http';
 
export class CustomQueryEncoderHelper implements HttpParameterCodec {
    decodeKey(key: string): string {
        return key;
    }
 
    decodeValue(value: string): string {
        return value;
    }
    encodeKey(k: string): string {
        return k.replace(/\+/gi, '%2B');
    }
    encodeValue(v: string): string {
        return v.toString().replace(/\+/gi, '%2B');
    }
}