Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Fixing hashids
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Oct 2, 2018
1 parent ddf1d3a commit 9ea9bc6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
"@angular/platform-browser-dynamic": "^6.1.7",
"@angular/router": "^6.1.7",
"@auth0/angular-jwt": "^2.0.0",
"@types/hashids": "^1.0.30",
"angular2-toaster": "^6.1.0",
"bootswatch": "^4.1.3",
"clipboard": "^1.7.1",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"hashids": "^1.1.1",
"hashids": "^1.2.2",
"markdown-it": "^8.3.1",
"moment": "^2.22.1",
"ngx-bootstrap": "^2.0.5",
Expand Down
10 changes: 5 additions & 5 deletions ui/src/app/shared/tools.class.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MessageType, User, Candidate, Question, DecodedHashId } from './';

import * as Hashids from 'hashids';
import {default as Hashids} from 'hashids';

export class Tools {

Expand Down Expand Up @@ -67,22 +67,22 @@ export class Tools {


static decodeHashId(hashId: string): DecodedHashId {
let hashids = new Hashids();
let hashids = new Hashids("");
if (hashId.startsWith(this.hashIdReadOnlyPrefix)) {
return {
id: hashids.decode(hashId.split(this.hashIdReadOnlyPrefix)[1]),
id: hashids.decode(hashId.split(this.hashIdReadOnlyPrefix)[1])[0],
readOnly: true
}
} else {
return {
id: hashids.decode(hashId),
id: hashids.decode(hashId)[0],
readOnly: false
}
}
}

static encodeHashId(id: number, readOnly: boolean = false): string {
let hashids = new Hashids();
let hashids = new Hashids("");

if (!readOnly) {
return hashids.encode(id);
Expand Down
14 changes: 13 additions & 1 deletion ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,23 @@
semver "^5.3.0"
semver-intersect "^1.1.2"

"@types/hashids@^1.0.30":
version "1.0.30"
resolved "https://registry.yarnpkg.com/@types/hashids/-/hashids-1.0.30.tgz#c0a056b25c5b13c80bf330fb8d379ac4d4049999"
integrity sha512-ESXJxz/GRY+SGa3n0WuWZLR0xM3k8LTr4+2xOoj/a0ZThglF/UfEeKVaMQNNFvFQ+mw3ng8LbC3gmJx/GmR5EQ==
dependencies:
"@types/node" "*"

"@types/jasmine@2.5.38":
version "2.5.38"
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.5.38.tgz#a4379124c4921d4e21de54ec74669c9e9b356717"
integrity sha1-pDeRJMSSHU4h3lTsdGacnps1Zxc=

"@types/node@*":
version "10.11.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.11.3.tgz#c055536ac8a5e871701aa01914be5731539d01ee"
integrity sha512-3AvcEJAh9EMatxs+OxAlvAEs7OTy6AG94mcH1iqyVDwVVndekLxzwkWQ/Z4SDbY6GO2oyUXyWW8tQ4rENSSQVQ==

"@types/node@^6.0.46", "@types/node@~6.0.60":
version "6.0.117"
resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.117.tgz#ccfc2506001404708528d657aad9c1b931111646"
Expand Down Expand Up @@ -3079,7 +3091,7 @@ hash.js@^1.0.0, hash.js@^1.0.3:
inherits "^2.0.3"
minimalistic-assert "^1.0.1"

hashids@^1.1.1:
hashids@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/hashids/-/hashids-1.2.2.tgz#28635c7f2f7360ba463686078eee837479e8eafb"
integrity sha512-dEHCG2LraR6PNvSGxosZHIRgxF5sNLOIBFEHbj8lfP9WWmu/PWPMzsip1drdVSOFi51N2pU7gZavrgn7sbGFuw==
Expand Down

0 comments on commit 9ea9bc6

Please sign in to comment.