@microsoft/kiota-serialization-form
Version:
Implementation of Kiota Serialization interfaces for URI from encoded
36 lines • 1.48 kB
JavaScript
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
import { FormParseNode } from "./formParseNode.js";
export class FormParseNodeFactory {
/**
* Creates an instance of JsonParseNode.
* @param backingStoreFactory - The factory to create backing stores.
*/
constructor(backingStoreFactory) {
this.backingStoreFactory = backingStoreFactory;
}
getValidContentType() {
return "application/x-www-form-urlencoded";
}
getRootParseNode(contentType, content) {
if (!content) {
throw new Error("content cannot be undefined of empty");
}
else if (!contentType) {
throw new Error("content type cannot be undefined or empty");
}
else if (this.getValidContentType() !== contentType) {
throw new Error(`expected a ${this.getValidContentType()} content type`);
}
return new FormParseNode(this.convertArrayBufferToString(content), this.backingStoreFactory);
}
convertArrayBufferToString(content) {
const decoder = new TextDecoder();
return decoder.decode(content);
}
}
//# sourceMappingURL=formParseNodeFactory.js.map