Skip to content

Commit f0611a9

Browse files
author
David Reed
committed
unused protocol encoding
1 parent dbc01b3 commit f0611a9

File tree

1 file changed

+0
-44
lines changed

1 file changed

+0
-44
lines changed

src/rewrite/index.js

-44
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ import UVClient from '../client/index.js';
3838
import BareClient from '@tomphttp/bare-client';
3939
import EventEmitter from 'events';
4040

41-
const valid_chars =
42-
"!#$%&'*+-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz|~";
43-
const reserved_chars = '%';
44-
4541
class Ultraviolet {
4642
constructor(options = {}) {
4743
this.prefix = options.prefix || '/service/';
@@ -133,46 +129,6 @@ class Ultraviolet {
133129
decodeUrl(str) {
134130
return decodeURIComponent(str);
135131
}
136-
encodeProtocol(protocol) {
137-
protocol = protocol.toString();
138-
139-
let result = '';
140-
141-
for (let i = 0; i < protocol.length; i++) {
142-
const char = protocol[i];
143-
144-
if (valid_chars.includes(char) && !reserved_chars.includes(char)) {
145-
result += char;
146-
} else {
147-
const code = char.charCodeAt();
148-
result += '%' + code.toString(16).padStart(2, 0);
149-
}
150-
}
151-
152-
return result;
153-
}
154-
decodeProtocol(protocol) {
155-
if (typeof protocol != 'string')
156-
throw new TypeError('protocol must be a string');
157-
158-
let result = '';
159-
160-
for (let i = 0; i < protocol.length; i++) {
161-
const char = protocol[i];
162-
163-
if (char == '%') {
164-
const code = parseInt(protocol.slice(i + 1, i + 3), 16);
165-
const decoded = String.fromCharCode(code);
166-
167-
result += decoded;
168-
i += 2;
169-
} else {
170-
result += char;
171-
}
172-
}
173-
174-
return result;
175-
}
176132
implementUVMiddleware() {
177133
// HTML
178134
attributes(this);

0 commit comments

Comments
 (0)