mirror of
https://github.com/sakaljurgis/kodi-api-server.git
synced 2026-07-08 20:37:41 +00:00
add initial frame, kodi api module, static serve module, settings, etc.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
|
||||
import RequestRangeBytes from './request-range-bytes.class';
|
||||
|
||||
export const RequestRange = createParamDecorator(
|
||||
(data: string, ctx: ExecutionContext): RequestRangeBytes | null => {
|
||||
const request = ctx.switchToHttp().getRequest().headers;
|
||||
|
||||
const range = request['range'];
|
||||
if (!range) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const array = range.split(/bytes=([0-9]*)-([0-9]*)/);
|
||||
|
||||
let start = parseInt(array[1]);
|
||||
let end = parseInt(array[2]);
|
||||
|
||||
//both isNaN? -> incorrect request header, response with everything we have
|
||||
start = isNaN(start) ? null : start; //isNaN? -> only num of end bytes requested
|
||||
end = isNaN(end) ? null : end; //isNaN? -> everything from start to the end requested
|
||||
|
||||
return new RequestRangeBytes(start, end);
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user